forked from c-koi/libboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard_font_text.cpp
49 lines (43 loc) · 1.33 KB
/
board_font_text.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @file board_font_text.cpp
* @author Sebastien Fourey (GREYC)
*
* @brief Sample use of Board's font
*
* This source code is part of the Board project, a C++ library whose
* purpose is to allow simple drawings in EPS, FIG or SVG files.
* Copyright (C) 2007 Sebastien Fourey <https://fourey.users.greyc.fr>
*/
#include <Board.h>
#include <board/BoardFontText.h>
#include <board/Tools.h>
#include <ctime>
using namespace LibBoard;
Group text()
{
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");
}