In my current line of work, SVG images forms a critical part of our production environment.
So much so that I’ve started an open source project that extends the Xojo Graphics object with a DrawSVG method. This method is still work in progress, but all the basic elements, together with transformations are already implemented.
Thanks for everyone that has unselfishly shared their expertise and code samples to get this project off the ground.
I’m currently working on the PATH element, which some of you might know to be a heavily used element of SVG. So don’t expect SVG’s that relies on this element to render correctly just yet. I hope to eventually grow this project into a full implementation of SVG 1.1.
Using the method in your own projects is very easy. Just copy the DrawSVG module from the project found at the link below to your own project, and your Graphics object will have a brand new DrawSVG method. You use it exactly how you would use the DrawPicture method, except that you need to supply SVG XML for drawing instead of a Picture object.
Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.DrawSVG "Some SVG XML", 100, 100 End Sub
Like I mentioned, this project is still work in progress, and you will find that there are still lots of missing features. I’m committed however to improve the feature set on a daily basis.
If there are any particular SVG images that you need rendered with this method, that currently doesn’t render with the method as it stands now, you are more than welcome to private message me with the sample SVG (or even post it in this conversation for general discussion). This will help me prioritize which features to attend to first.
If you are a Mac or a Linux user, I would love to hear if the module works on these platforms. All my work is done on Windows and I haven’t had time yet to test it on these platforms.
Here is a screenshot of some test SVGs that the method can already render successfully: