Hi, this is how I’m currently handling drawing custom SVG controls, is this the best way to go about things?
I have 2 elements, one which gets rotated, the other that doesn’t, loaded at startup:
p_rot = Drawable::createFromSVGFile( File( “c:\temp\knobs\knob1b.svg” ) );
p_rot_bg = Drawable::createFromSVGFile( File( “c:\temp\knobs\knob1a.svg” ) );
In the drawRotarySlider LAF method these 2 elements are scaled, rotated, and translated into position:
AffineTransform at = AffineTransform::scale( scale_x, scale_y ).rotated( angle, pivotX, pivotY ).translated( x, y );
p_rot->draw( g, 1.0, at );
I think it renders though whatever renderer you are using, however the OpenGL renderer doesn’t really do all the fancy stuff you might if you were writing your own shaders.
You can probably get a massive speed up by caching the rendered knob as an image. (See the Graphics(Image &) constructor).
Cheers Jim - I’ve just been thinking about caching actually as it’s the same thing over and over again - was looking into the CachedImage class, but will check out your suggestion also. thx
Depending of the content of your SVG, rotating and scaling an image might be more expensive than rotating the primitives and drawing them directly.
Also you avoid the artefacts/blur that comes with rotating images.