From 4166b2c124b0bc652e9f8e5245488cdd2b86ebf0 Mon Sep 17 00:00:00 2001 From: Sam Moore Date: Tue, 12 Aug 2014 15:14:40 +0800 Subject: [PATCH] SVG text and line elements Totally not done properly but whatever --- src/document.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/document.cpp b/src/document.cpp index fe3482f..f23b406 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -291,6 +291,15 @@ void Document::ParseSVGNode(pugi::xml_node & root, const Rect & bounds, Real & w Debug("Path data attribute is \"%s\"", d.c_str()); ParseSVGPathData(d, Rect(bounds.x,bounds.y,width,height)); } + else if (strcmp(child.name(), "line") == 0) + { + Real x0(child.attribute("x1").as_float()/width + bounds.x); + Real y0(child.attribute("y1").as_float()/height + bounds.y); + Real x1(child.attribute("x2").as_float()/width + bounds.x); + Real y1(child.attribute("y2").as_float()/height + bounds.y); + unsigned index = AddBezierData(Bezier(x0,y0,x1,y1,x1,y1,x1,y1)); + Add(BEZIER, Rect(0,0,1,1), index); + } else if (strcmp(child.name(), "rect") == 0) { Real coords[4]; @@ -316,6 +325,13 @@ void Document::ParseSVGNode(pugi::xml_node & root, const Rect & bounds, Real & w Add(CIRCLE_FILLED, rect,0); Debug("Added Circle %s", rect.Str().c_str()); } + else if (strcmp(child.name(), "text") == 0) + { + Real x = child.attribute("x").as_float()/width + bounds.x; + Real y = child.attribute("y").as_float()/height + bounds.y; + Debug("Add text \"%s\"", child.child_value()); + AddText(child.child_value(), 0.05, x, y); + } } } -- 2.20.1