Drawing knobs by drawImageTransformed - performence

Sorry I have question for which I probably could get answer by myself, but it’s time consuming so maybe anybody has already that experienced?

In many projects I’ve already seen that knobs are very long image files (I mean very high and very narrow) with separated frame drawings for each angle position of knob. And then when drawing knob they crop that image to one frame, and then just changing position of image to crop frame with appropriate angle. But preparing such image file with all frames is time consuming (at least for me) especially if you have many different knobs look.

But I see in juce documentation there is method drawImageTransformed(). It allows you to use just one drawing and change the angle of it by AffineTransform.
It seems to be much smarter then preparing many frames of one knob.

But I wonder about performence of those two methods to drawing knobs. Can anyone give some advice? Have anyone some experience with those two methods and could tell about some comparison in the concern of performence?

Short answer: you don’t want a shadow to be rotated


OK heh!!!, But my knobs don’t have shadows. The are completly flat :slight_smile:
That’s why I am asking about performence between rotating by AffineTransform::rotation(angle, centerX, centerY) and shifting bigger image to crop appropriate knob angle frame?

Or maybe do you think vectorize (mean drawing primitive elements like circle or triangles by Graphics) is even better in my situation?

Actually my knobs are very simple: one big circle, one smaller circle (in different colour) and value indicator (triangle).

And I design them by drawing primitives by Graphics. But after designing process I changed those knobs to *.png files. And then in myKnobLAF::drawRotarySlider() I just draw that png file.

I think in my case it gives me better performance then drawing vectorized primitives. But maybe my tests are not appropriate.

Please notice I have about 10 knobs in my plugin, and they all can be automatized in host.

As the performance will highly depend on how complex your slider should look like, and how many steps you would like it to have, the only thing I can say is: profile it, measure it for your specific use-case.