Openframeworks add-on for loading and parsing svg files.
Forks
Forks pushed to more recently than NickHardeman/ofxSvgParser itself, plus any admin-confirmed fork with commits of its own — worth checking if you're hitting issues with the original.
README
ofxSvgParser
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.
ofxAddons