blob: e855dab20016aeefab926da5c1043edf3a317991 (
plain)
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
|
#include <sstream>
#include "svg.h"
Polygon::Polygon(std::vector<std::array<double, 2>> pts, std::string bg)
: pts{move(pts)}, bg{move(bg)}
{}
std::string Polygon::svg() const {
std::ostringstream ss;
ss << "<path d=\"";
for (size_t i = 0; i < pts.size(); i++) {
if (i == 0) ss << 'M'; else ss << 'L';
ss << pts[i][0] << ' ' << pts[i][1] << ' ';
}
ss << "Z\" stroke=\"black\" fill=\"" << bg << "\" stroke-width=\"0.03px\"/>";
return ss.str();
}
Text::Text(double x, double y, double rotation, std::string text)
: x{x}, y{y}, rotation{rotation}, text{move(text)}
{}
std::string Text::svg() const {
std::ostringstream ss;
ss << "<text x=\"" << x << "\" y=\"" << y - 0.04 << "\" transform=\"rotate(" << rotation << ")\" style=\"font-size:0.3px\" text-anchor=\"middle\" dominant-baseline=\"middle\">";
ss << text << "</text>";
return ss.str();
}
|