#include <ctime>
#include <set>
#include <vector>
{
Board::enableLineWidthScaling();
board.
clear(Color::White);
Tools::initBoardRand(static_cast<unsigned int>(time(nullptr)));
board <<
Line(-50, 0, 650, 0, Color::Red);
board <<
Line(-50, 300, 650, -300, Color::Red);
board.
last<
Line>().rotate(90 * Board::Degree);
Polyline p(losange, Style::defaultPenColor(), Color::Green);
board << p;
board.
rotate(45 * Board::Degree);
Polyline square(Path::Closed, Color::Black,
Color(70, 70, 130), 0.1);
int n = 80;
std::set<std::pair<int, int>> holes;
while (n--) {
holes.insert(std::make_pair((int)(Tools::boardRand() % 20) - 10, (int)(Tools::boardRand() % 20) - 10));
}
std::set<std::pair<int, int>>::iterator it = holes.begin();
while (it != holes.end()) {
Point p(it->first * 10, it->second * 10);
square.addHole(hole);
++it;
}
board << square.scaled(3).translated(1000, 0).rotated(45 * Board::Degree);
board.
saveEPS(
"holes.eps", PageSize::A4);
board.
saveSVG(
"holes.svg", PageSize::BoundingBox, 0.0, Unit::Centimeter);
}
Declaration of the Board class.
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Structure representing an RGB triple.
Definition Color.h:43
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
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 & rotate(double angle, const Point ¢er) override
Rotate the board by an angle around a point.
Definition Board.cpp:155
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 Line.h:38
A path, according to Postscript and SVG definition.
Definition Path.h:45
Path & scale(double sx, double sy)
Apply a scaling factor to the path along each axis.
Definition Path.cpp:169
void close()
Close the path.
Definition Path.h:453
Struct representing a 2D point.
Definition Point.h:42
double y
Definition Point.h:44
double x
Definition Point.h:43
A polygonal line described by a series of 2D points.
Definition Polyline.h:38
void addHole(const Path &path)
Add a hole to the path. Warning: Hole share the polyline line style.
Definition Polyline.cpp:152
ShapeList & append(const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
Definition ShapeList.cpp:232
T & last(const std::size_t position=0)
Definition ShapeList.h:505
Shape & scaleToWidth(double w, LineWidthFlag lineWidthFlag)
Definition Shape.cpp:85