Board 0.9.6
examples/example4.cpp
#include <Board.h>
using namespace LibBoard;
int main(int, char *[])
{
Board board;
board.clear(Color(200, 255, 200));
board.setLineWidth(0.01); // For Board drawing methods.
Style::setDefaultLineWidth(0.02); // For all Shapes constructors.
for (double x = -20.0; x <= 20; x += 1.0)
for (double y = -20.0; y <= 20; y += 1.0) {
board << Dot(x, y, Color::Black);
board.setPenColorRGBf(1.0, 0.0, 0.0);
board.drawDot(x + 0.2, y + 0.2);
}
Group g;
g << Line(-5, 2, 5, 2, Color::Red) << LibBoard::rectangle(-5, 2, 1, 4, Color::Null, Color::Blue) << LibBoard::rectangle(4, 2, 1, 4, Color::Null, Color::Blue)
<< Ellipse(0, 0, 5, 2, Color::Red, Color::Null);
Group g2(g);
Group g3(g);
g2.translate(0, 6);
g3.translate(0, -6);
Group f;
f << g << g2 << g3;
f.rotateDeg(45.0);
board << f;
Ellipse c = LibBoard::circle(2, 5, 1.8, Color::Red, Color::Green);
for (int i = 0; i < 5; ++i) {
l << c.scale(1, 0.5);
}
for (double x = -20, a = 0; x < 20; x += 4, a += 0.3) {
board << l.rotated(a).translate(x, 10);
}
g.clear();
Polyline r1 = LibBoard::rectangle(2, 2, 3, 1, Color::Black, Color::Null);
Polyline r2 = r1.translated(-8, -8);
for (double alpha = 0; alpha < 2 * M_PI; alpha += 0.2) {
g << r1.rotated(alpha);
board << r2.rotated(alpha, r2[0]);
}
board.saveEPS("example4.eps", PageSize::A4);
board.saveFIG("example4.fig", PageSize::A4);
board.scaleToWidth(10, UseLineWidth);
board.saveSVG("example4.svg", PageSize::BoundingBox, 0.0, Unit::Centimeter);
}
Declaration of the Board class.
#define M_PI
Definition Shape.h:46
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Structure representing an RGB triple.
Definition Color.h:43
Definition Board.h:55
Ellipse circle(double x, double y, double radius, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle())
Definition Ellipse.cpp:371
Polyline rectangle(double left, double top, double width, double height, Color penColor=Style::defaultPenColor(), Color fillColor=Style::defaultFillColor(), double lineWidth=Style::defaultLineWidth(), const LineStyle lineStyle=Style::defaultLineStyle(), const LineCap cap=Style::defaultLineCap(), const LineJoin join=Style::defaultLineJoin())
Definition Polyline.cpp:569
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
void saveFIG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:636
void drawDot(double x, double y)
Definition Board.cpp:298
Board & setPenColorRGBf(float red, float green, float blue, float alpha=1.0f)
Definition Board.cpp:238
void saveEPS(std::ostream &out, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter, const std::string &title=std::string()) const
Definition Board.cpp:539
Board & setLineWidth(double width)
Definition Board.cpp:274
void clear(const Color &color=Color::Null)
Definition Board.cpp:149
void saveSVG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:765
A line between two points.
Definition Dot.h:42
An ellipse.
Definition Ellipse.h:38
Ellipse & scale(double sx, double sy) override
Definition Ellipse.cpp:98
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
Group & translate(double dx, double dy) override
Definition Group.cpp:70
A line between two points.
Definition Line.h:38
A polygonal line described by a series of 2D points.
Definition Polyline.h:38
Polyline rotated(double angle, const Point &center) const
Definition Polyline.cpp:72
Polyline translated(double dx, double dy) const
Definition Polyline.cpp:99
A group of shapes.
Definition ShapeList.h:47
ShapeList rotated(double angle, const Point &center)
Definition ShapeList.cpp:298
ShapeList & translate(double dx, double dy) override
Definition ShapeList.cpp:314
ShapeList & clear()
Definition ShapeList.cpp:90
Shape & rotateDeg(double angle, const Point &center)
Definition Shape.h:337
Shape & scaleToWidth(double w, LineWidthFlag lineWidthFlag)
Definition Shape.cpp:85