Board 0.9.6
examples/interpolate.cpp
#include <Board.h>
using namespace LibBoard;
{
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 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");
}
Declaration of the Board class.
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Structure representing an RGB triple.
Definition Color.h:43
Group mustache()
Definition interpolate.cpp:32
Group interpolate()
Definition interpolate.cpp:14
Definition Board.h:55
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
Board & setPenColor(const Color &color)
Definition Board.cpp:244
Board & setFillColor(const Color &color)
Definition Board.cpp:268
Board & setLineWidth(double width)
Definition Board.cpp:274
void saveSVG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:765
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
A line between two points.
Definition Line.h:38
A path, according to Postscript and SVG definition.
Definition Path.h:45
const std::vector< Point > & points() const
Definition Path.cpp:371
std::size_t size() const
The number of points in the path.
Definition Path.h:448
Struct representing a 2D point.
Definition Point.h:42
A polygonal line described by a series of 2D points.
Definition Polyline.h:38
ShapeList & append(const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
Definition ShapeList.cpp:232
Definition Style.h:69
Color penColor
Definition Style.h:70