SVG to juce draw commands


#1

I know it's kinda strange request, but anybody has a SVG to juce C++ converter utility (or done something similar) ? Something that converts a simple SVG to juce Path and Graphics drawing code...

I know i can look at the Drawable code to take inspiration but this would definately save me some time...

Any suggestion is really appreciated :)


#2

Have you seen the SVG path helper in the tools menu of the Introjucer? Does this solve your problem?


#3

Like paintcode on osx :)


#4

exactly... only for juce :)


#5

well, yes and no. it doesn't generate the single path generation commands but it convert the path to a binary string:


static const unsigned char pathData[] = { 110,109,102,102,62,65,102,102,190,64,98,102,102,62,65,119,190,19,65,119,190,19,65,102,102,62,65,102,102,190,64,102,102,62,65,98,190,159,42,64,102,102,62,65,0,0,0,0,119,190,19,65,0,0,0,0,102,102,190,64,98,0,0,0,0,190,159,42,64,190,159,42,64,0,0,0,0,102,
102,190,64,0,0,0,0,98,119,190,19,65,0,0,0,0,102,102,62,65,190,159,42,64,102,102,62,65,102,102,190,64,99,101,0,0 };

Path path;
path.loadPathFromData (pathData, sizeof (pathData));

This isn't exaclty what i'm looking for...

Also, it doesn't take AffineTransform and fill/stroke with Colour and Gradient classes (which is the tricky part).


#6

It'd be a fun project, though TBH not sure how much sense it would make - I don't think that generated code would be significantly faster than just loading SVG as a Drawable and drawing it.


#7

it's not about drawing speed, it's about speed of reusing svg controls created by graphic artists and tweak them in code based on the state (for example change a single path stroke color without having to mess with another svg, import it and so on).

If you want to change part of an svg on the fly that's the only way, convert it to juce draw calls. Sure i can make the graphic designer use the Introjucer to draw but that's far from optimal (and the designer is going to insult me a lot of times when he discover there is no path::union or path::intersection features in Introjucer, just to name a few)...