Openframeworks add-on for loading and parsing svg files.
Compatible with OpenFrameworks >= 12.0.
The goal of this addon is to load and parse svg files while maintaining the structure of the file, ie groups and children, etc. Helpful for layout and placement of interactive elements or storing path information. The focus of this addon is placement and file structure; not rendering. So clipping, gradients and other rasterization implementations are not supported.
Grab a group by passing in the name of the group.
shared_ptr<ofxSvgGroup> logoGroup = svg.get<ofxSvgGroup>("logo");
Grab nested groups by passing in the hierarchy to the group separated by colons.
shared_ptr<ofxSvgGroup> cloudGroup = svg.get<ofxSvgGroup>("sky:clouds");
Get all of the elements of a certain type by calling getElementsForType
vector< shared_ptr<ofxSvgImage> > trees = svg.getElementsForType<ofxSvgImage>("trees");
Currently supports the following types:
Group, Rectangle, Image, Ellipse, Circle, Path, Polygon and Line
Limited Support:
Text
The addon will attempt to load system fonts. It also searches for a folder named "fonts" in the same directory as the loaded svg file for cross platform compatability.
Text has limited support due to the breadth and complexity of the spec.
This is the successor to ofxSvgLoader (/~https://github.com/NickHardeman/ofxSvgLoader).
ofxSvgParser has no external dependencies ( other than OF :)
Previously, ofxSvgLoader depended on ofxSvg, which depended on svgtiny to parse the paths and polygons.
This addon parses the svg document internally based on the W3 svg 2.0 spec (https://www.w3.org/TR/SVG2/Overview.html).
The svg spec is quite large and quite ambiguous at times. I have tested with several sample svg files, but please submit an issue if something is incorrect.