MCPcopy Create free account
hub / github.com/MyGUI/mygui / writeSvgPathDef

Function writeSvgPathDef

MyGUIEngine/src/msdfgen/core/export-svg.cpp:13–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13static void writeSvgPathDef(FILE *f, const Shape &shape) {
14 bool beginning = true;
15 for (const Contour &c : shape.contours) {
16 if (c.edges.empty())
17 continue;
18 if (beginning)
19 beginning = false;
20 else
21 fputc(' ', f);
22 fputs("M ", f);
23 writeSvgCoord(f, c.edges[0]->controlPoints()[0]);
24 for (const EdgeHolder &e : c.edges) {
25 const Point2 *cp = e->controlPoints();
26 switch (e->type()) {
27 case (int) LinearSegment::EDGE_TYPE:
28 fputs(" L ", f);
29 writeSvgCoord(f, cp[1]);
30 break;
31 case (int) QuadraticSegment::EDGE_TYPE:
32 fputs(" Q ", f);
33 writeSvgCoord(f, cp[1]);
34 fputc(' ', f);
35 writeSvgCoord(f, cp[2]);
36 break;
37 case (int) CubicSegment::EDGE_TYPE:
38 fputs(" C ", f);
39 writeSvgCoord(f, cp[1]);
40 fputc(' ', f);
41 writeSvgCoord(f, cp[2]);
42 fputc(' ', f);
43 writeSvgCoord(f, cp[3]);
44 break;
45 }
46 }
47 fputs(" Z", f);
48 }
49}
50
51bool saveSvgShape(const Shape &shape, const char *filename) {
52 if (FILE *f = fopen(filename, "w")) {

Callers 1

saveSvgShapeFunction · 0.85

Calls 4

writeSvgCoordFunction · 0.85
controlPointsMethod · 0.80
emptyMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected