I made a little script that parses a SVG file to extract the information about the paths and converts it to functions to put in OF draw() method. The script is still buggy, but works for many cases of bezier draws of inkscape. I’m working to provide options like insert varibles to move the drawing in the screen.
I tried your script…it worked on your .svg file but didn’t complete the coordinates on mine (almost worked but I think it encountered some parsing error):
Thanks for check this ugly script ;D, i made a change and now works with box.svg and kv.svg. Really i don’t know if it is the better way. I don’t know what general is, but sometimes works.
I came across your post cos I would like to extract the paths of some SVG files to OF format,
but somehow your script keeps working only with the sample .svg you provided…
I create the SVGs using Illustrator 4.0. What could go wrong?
By the way:
Is it possible to also extract polygon information as ofVertex? (it should be even more straightforward but since I don’t know how to use ruby I prefer to ask u
I have an svg importer addon in the works I can upload it after this weekend.
It will come with a bunch of parsing bugs though - the svg spec is pretty nuts!
Here it is - very rough for now - no example app and probably a little buggy.
It was mainly done to load paths, but it also can do lines, circles, rects, polygons.
Currently doesn’t do multiple contours in one path and if you have your element in groups it will totally break. These are not tricky things to fix but just didn’t have time to add more than what I needed.
Shapes can draw themselves and there is also a svgShapeInterpretur class that turns paths and curves into resampled straightline points (similar to how OF draws curves)
Sorry I could not manage to post that earlier - but I think the svgLoader has a small issue with lines:
if there is a svg shape which contains only two pts - for example a line you correctly detect it but than the drawing fails since ofVertex needs at least 3 pts, I am correct?
Thx a lot for the contribution anyway, it just saved my ass in a small project