Board 0.9.6
examples/board_font_text.cpp
#include <Board.h>
#include <board/Tools.h>
#include <ctime>
using namespace LibBoard;
{
Group g;
std::string s;
for (int c = '!'; c <= '~'; ++c) {
s.push_back((char)c);
}
g = boardFontText(Point(10, 20), s, 40);
g << Line(Point(10, 20), Point(10 + g.boundingBox(LineWidthFlag::UseLineWidth).width, 20), Color::Black);
g.accept(ShapeWithStyleVisitor(Color::Red, Color::Null));
g.append(makeRough(boardFontText(Point(0, 0), s, 40), 1), Direction::Bottom, Alignment::Left);
g << Dot(0, 0);
return framed(g, 10.0, Color::Black, Color::White, 1.0);
}
int main(int, char *[])
{
auto t = time(nullptr);
Tools::initBoardRand(static_cast<unsigned long>(t));
Board board;
Board::disableLineWidthScaling();
Style::setDefaultLineWidth(1);
board.setLineWidth(0.5);
board.setPenColor(Color::Blue);
board.setFillColor(Color::Red);
board << text();
board.saveSVG("board_font_text.svg", PageSize::BoundingBox);
// system("svgviewer board_font_text.svg");
}
Group class.
Declaration of the Board class.
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Group text()
Definition board_font_text.cpp:17
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 line between two points.
Definition Dot.h:42
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 * accept(CompositeShapeTransform &transform) const override
Accept a composite shape transform.
Definition Group.cpp:221
Rect boundingBox(LineWidthFlag) const override
Definition Group.cpp:212
A line between two points.
Definition Line.h:38
Struct representing a 2D point.
Definition Point.h:42
double width
Definition Rect.h:43
ShapeList & push_back(Shape *shape)
Definition ShapeList.cpp:427
ShapeList & append(const Shape &shape, Direction direction=Direction::Right, Alignment alignment=Alignment::Center, double margin=0.0, LineWidthFlag lineWidthFlag=UseLineWidth)
Definition ShapeList.cpp:232
Leaf visitor may be used to apply a function on each Shape with style, in back-to-front order.
Definition ShapeVisitor.h:248