29 s += std::to_string(
int(c.
r*255)) +
"," + std::to_string(
int(c.
g*255)) +
"," + std::to_string(
int(c.
b*255));
37 s +=
"<defs><linearGradient id=\"";
39 s +=
"\" x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\">";
40 s +=
"<stop offset=\"0%\" style=\"stop-color:";
42 s +=
";stop-opacity:1\" />";
43 s +=
"<stop offset=\"100%\" style=\"stop-color:";
45 s +=
";stop-opacity:1\" />";
46 s +=
"</linearGradient></defs>";
76 double epsilon = 0.05;
78 s +=
"<rect x=\"" + std::to_string(10*x-epsilon);
79 s +=
"\" y=\"" + std::to_string(10*y-epsilon);
80 s +=
"\" width=\""+std::to_string(
width*10+2*epsilon)+
"\" height=\""+std::to_string(
height*10+2*epsilon)+
"\" ";
84 s +=
" style=\"stroke-width:1\" />";
106 s +=
";stroke-width:"+std::to_string(border)+
"\" />";
112 double resolution =
TWOPI/segments;
114 s +=
"<polygon points=\"";
116 for (
int x = 0; x <= segments; x++)
123 s +=
"\" style=\"fill:none;stroke:purple;stroke-width:1\" />";
129 double resolution =
TWOPI/segments;
131 s +=
"<polygon points=\"";
133 for (
int x = 0; x <= segments; x++)
140 s +=
"\" style=\"fill:"+
SVGGetRGB(c)+
"\" />";
149 return "<path stroke-linejoin=\"round\" stroke-linecap=\"round\" stroke=\""+
SVGGetRGB(c)+
"\" stroke-width=\""+std::to_string(
width)+
"\" fill=\"none\" d=\"";
164 return "L "+std::to_string(x1)+
" "+std::to_string(y1)+
" ";
169 return "M "+std::to_string(x1)+
" "+std::to_string(y1)+
" L "+std::to_string(x2)+
" "+std::to_string(y2)+
" ";
173 {
return "\" />\n"; }
178 std::string s =
"<path d=\"";
180 s +=
"M "+std::to_string(lines[0].x)+
" "+std::to_string(lines[0].y)+
" L";
182 for (
size_t x = 1; x < lines.size(); x++)
184 s +=
" "+std::to_string(lines[x].x)+
" "+std::to_string(lines[x].y)+
" ";
187 s +=
"\" stroke=\""+
SVGGetRGB(c)+
"\" stroke-width=\""+std::to_string(
width)+
"\" fill=\"none\" />\n";
195 s =
"<line x1 = \"" + std::to_string(x1) +
"\" ";
196 s +=
"y1 = \"" + std::to_string(y1) +
"\" ";
197 s +=
"x2 = \"" + std::to_string(x2) +
"\" ";
198 s +=
"y2 = \"" + std::to_string(y2) +
"\" ";
200 s +=
";stroke-width:"+std::to_string(
width)+
"\" stroke-linecap=\"round\" />";
207 float offset = center?0.5:0;
208 s =
"<line x1 = \"" + std::to_string(x1+offset) +
"\" ";
209 s +=
"y1 = \"" + std::to_string(y1+offset) +
"\" ";
210 s +=
"x2 = \"" + std::to_string(x2+offset) +
"\" ";
211 s +=
"y2 = \"" + std::to_string(y2+offset) +
"\" ";
213 s +=
";stroke-width:"+std::to_string(
width)+
"\" stroke-linecap=\"round\" />";
233 s =
"<text x=\""+std::to_string(x1)+
"\" y=\""+std::to_string(y1)+
"\" text-anchor=\"";
240 s +=
"; font-family:";
245 s +=
", sans-serif; font-weight:bold; font-size:"+std::to_string(size)+
"px\"";
248 s +=
" dominant-baseline=\"baseline\">";
251 s +=
" dominant-baseline=\"hanging\">";
254 s +=
" dominant-baseline=\"middle\">";
269 s =
"<text x=\""+std::to_string(x1*10+2)+
"\" y=\""+std::to_string(y1*10-1)+
"\" style=\"fill:"+
SVGGetRGB(c);
270 s +=
"; font-family:Impact, sans-serif; font-size:"+std::to_string(size*10)+
"px; stroke:"+
SVGGetRGB(strokeColor)+
"; stroke-width:"+std::to_string(size)+
"px; stroke-linecap:round;stroke-linejoin:round\">";
277 float WidthToSVG(
float w,
float xMultiplier,
float yMultiplier)
279 return std::min(xMultiplier, yMultiplier)*((w+1)/2.0-(0+1)/2.0);
284 return (p+1)*multiplier/2.0;
289 p.
x = (p.
x+1)*xmultiplier/2.0;
290 p.
y = (p.
y+1)*ymultiplier/2.0;
296 for (
size_t x = 0; x < drawCommands.size(); x++)
300 switch (drawCommands[x].what)
309 (drawCommands[x].line.width == drawCommands[x-1].line.width &&
310 drawCommands[x].line.c == drawCommands[x-1].line.c)))
319 else if (drawCommands[x-1].line.end == o.
start)
337 p2 *= (o.
end-newEnd).length();
369 drawCommands[x+1].shape.c == o.
c)
371 s +=
"<g style=\"fill:"+
SVGGetRGB(o.
c)+
";\">\n";
386 drawCommands[x].shape.c == o.
c)
455 s +=
"<polygon points=\""+
456 std::to_string(p1.
x)+
","+std::to_string(p1.
y)+
" "+
457 std::to_string(p2.
x)+
","+std::to_string(p2.
y)+
" "+
458 std::to_string(p3.
x)+
","+std::to_string(p3.
y)+
"\" ";
459 s +=
"style=\"fill:none;stroke:"+
SVGGetRGB(i.
c)+
";stroke-width:"+std::to_string(i.
width)+
"\" />";
474 s +=
"<polygon points=\""+
475 std::to_string(p1.
x)+
","+std::to_string(p1.
y)+
" "+
476 std::to_string(p2.
x)+
","+std::to_string(p2.
y)+
" "+
477 std::to_string(p3.
x)+
","+std::to_string(p3.
y)+
"\" ";
487 FILE *f = fopen(filename,
"w+");
490 printf(
"Error: Could not open file '%s'\n", filename);
505 s =
"<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width = \""+std::to_string(
width)+
"\" height = \""+std::to_string(
height)+
"\" ";
506 s +=
"viewBox = \"0 0 "+std::to_string(
width)+
" "+std::to_string(
height)+
"\" ";
511 s +=
" shape-rendering=\"crispEdges\"";
519 for (
size_t x = 0; x < disp.
text.size(); x++)
521 const auto &i = disp.
text[x];
539 static std::vector<Graphics::point> outputPoints;
545 outputPoints = i.points;
546 for (
auto &j : outputPoints)