Board
0.9.6
examples/interpolate.cpp
#include <
Board.h
>
using namespace
LibBoard
;
Group
interpolate
()
{
Group
g;
Path
a = {
Point
(0, 0),
Point
(50, 0),
Point
(100, 0),
Point
(150, 0),
Point
(200, 0)};
Path
b = {
Point
(0, 100),
Point
(50, 150),
Point
(100, 100),
Point
(150, 150),
Point
(200, 100)};
Polyline
pa(a, Color::Red);
Polyline
pb(b, Color::Green);
g << pa << pb;
for
(
double
t = 0.05; t < 1.0; t += 0.05) {
g << mix(pa, pb, t);
}
for
(
decltype
(a.
size
()) i = 0; i < a.
size
(); ++i) {
g <<
Line
(a[i], b[i], Color::Gray);
}
return
g;
}
Group
mustache
()
{
Group
g;
Path
p = {
Point
(100, 100),
Point
(150, 150),
Point
(200, 100)};
Color
c0 = Color::fromHueColormap(0.0f);
Color
c1 = Color::fromHueColormap(0.999f);
Style
style = Style::defaultStyle();
for
(
double
r = 0.0; r <= 2.0; r += 0.1) {
const
float
t =
static_cast<
float
>
(r) / 2.0f;
style.
penColor
= Color::mixHSV(c0, c1, t);
g << Bezier::smoothedPolyline(p.
points
(), r, style);
}
return
g;
}
int
main
(
int
,
char
*[])
{
Board
board;
Board::disableLineWidthScaling();
board.
setLineWidth
(0.1);
board.
setPenColor
(Color::Blue);
board.
setFillColor
(Color::Red);
board.
append
(
interpolate
(), Direction::Right, Alignment::Center, 5);
board.
append
(
mustache
(), Direction::Right, Alignment::Center, 5);
board.
saveSVG
(
"interpolate.svg"
, PageSize::BoundingBox);
// system("svgviewer interpolate.svg");
}
Board.h
Declaration of the Board class.
main
int main(int argc, char *argv[])
Definition
arithmetic.cpp:16
LibBoard::Color
Structure representing an RGB triple.
Definition
Color.h:43
mustache
Group mustache()
Definition
interpolate.cpp:32
interpolate
Group interpolate()
Definition
interpolate.cpp:14
LibBoard
Definition
Board.h:55
LibBoard::Board
Class for EPS, FIG or SVG drawings.
Definition
Board.h:61
LibBoard::Board::setPenColor
Board & setPenColor(const Color &color)
Definition
Board.cpp:244
LibBoard::Board::setFillColor
Board & setFillColor(const Color &color)
Definition
Board.cpp:268
LibBoard::Board::setLineWidth
Board & setLineWidth(double width)
Definition
Board.cpp:274
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition
Board.cpp:765
LibBoard::Group
A group of shapes. A group is basically a ShapeList except that when rendered in either an SVG of a F...
Definition
Group.h:40
LibBoard::Line
A line between two points.
Definition
Line.h:38
LibBoard::Path
A path, according to Postscript and SVG definition.
Definition
Path.h:45
LibBoard::Path::points
const std::vector< Point > & points() const
Definition
Path.cpp:371
LibBoard::Path::size
std::size_t size() const
The number of points in the path.
Definition
Path.h:448
LibBoard::Point
Struct representing a 2D point.
Definition
Point.h:42
LibBoard::Polyline
A polygonal line described by a series of 2D points.
Definition
Polyline.h:38
LibBoard::ShapeList::append
ShapeList & append(const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
Definition
ShapeList.cpp:232
LibBoard::Style
Definition
Style.h:69
LibBoard::Style::penColor
Color penColor
Definition
Style.h:70
Generated by
1.9.7