Update / rewrite of the ofxSvg addon to remove dependency on libTinySvg and libxml2.#8266
Conversation
|
This issue on windows might make the argument for ofxSvgEllipse instead of ofx::svg::Ellipse |
|
Fantastic @NickHardeman let me know when it is ready to test and I can test with a lot of SVGs from previous projects here |
Great, will do. I can also send a test app that loads an svg from a folder, saves it and reloads the saved one. Arrow keys to change index and load again in the directory. |
|
@dimitre I think it's ready for some testing now that it's passed the checks. Attached is a quick app for testing loading, saving and loading the saved svgs. The svgs in the folder are from https://www.svgviewer.dev and are just for testing complex paths. |
|
Great I've just seen now and tested some things. I'm testing with a very crude set of svgs and will report some things. |
|
@dimitre thank you for trying it out. I have fixed some of the fill issues that you mentioned. |
|
Hey Nick finally I've found this one again. I'm looking forward to see it merged :) |
|
it would be great to have this one merged. if you prefer it can have an alternative name, like ofxAssimpModelLoader / ofxAssimp |
|
@dimitre I agree, been doing a lot of work on the addon, implementing some text parsing and cleaning it up a bit. Text parsing is exhausting! |
|
Awesome! |
|
I'm now testing and found some issues with this files here |
|
Another item to consider is the removal of the svg tiny libs. Not sure about the best approach... |
@ofTheo was right; I just tried changing the winding order and it looks correct with OF_POLY_WINDING_POSITIVE. However, calling getOutlines() no longer returns a vector of ofPolylines since there is no stroke width on the path. Wondering if we could duplicate this functionality |
…f OF_POLY_WINDING_NONZERO with a function to set it differently.
|
The ofPath::getOutline() seems like a separate issue and I think can be addressed outside of this thread. |
|
Cool - I am good to merge this! |
|
Super! I'll be able to test next week and report back if anything. |
|
I'm now testing ofxSvg. I had some issues with this SVGs and I'll be testing more soon |
|
heyyy sorry ignore the last one. they are all good. I merged changes somewhere else and tested in another OF copy. |
|
I have issue with this one (hanging the software) here |
|
Ok more info now. it works OK if I comment out It loads OK but hangs trying to draw element number 114 in this SVG. I'll update with more info later |










Proposing this update to ofxSvg with the following implementation based on my ofx::svg::Parser addon (https://github.com/NickHardeman/ofxSvgParser).
This rewrite adds the following functionality:
Loading of elements with search functionality
Remove libtinysvg and libxml2 dependencies. The parsing is happening in the ofxSvg class ( it took a while getting through the spec on paths :0 and parsing/writing CSS manually ;) )
Add elements to the document
Save the document after loading or adding / removing elements.
Works with the current ofxSvg example.
Grab a group by passing in the name of the group.
auto logoGroup = svg.get("logo");
Grab nested groups by passing in the hierarchy to the group separated by colons.
auto cloudGroup = svg.get("sky:clouds");
Get all of the elements of a certain type by calling getElementsForType
auto sprinklePaths = svg.getElementsForType("Donut:Sprinkles");
Currently supports the following types:
Group, Rectangle, Image (linked and embedded), Ellipse, Circle, Path, Polygon and Line
Limited Parsing Support:
Text
We have been using some version of this for parsing svg in our projects for the last several years.
TODO: