drawImageTransformed question

Hi, simple question:

I'm rotating an image with Graphics.drawImageTransformed but i want to be able to draw it where ever i want not just at x0, y0.

I tried:

af = AffineTransform.rotation(rot).translation(mX, mY);

But it doesn't work because then only the translation is applied and not the rotation.

How can I achieve both?


As so often happens, I don't know the answer, but have you checked how the Demo app does it?

All-sorts are rotated, scaled, streched and skewed there...

Checkout GraphicsDemo.cpp's GraphicsDemoBase class

Thanks for the reminder! I guess I should have looked there first thing.

I completely overlooked the followedBy method:

AffineTransform.rotation(rot,0,0).followedBy(AffineTransform.translation(mX, mY));


The reason the rotation was missing after your previous attempt was that you were using the static 'translation' function, which creates a new translation. You should have instead been using 'translated', which is not static, and returns a translated version of the object it is called on.

Have another look at the docs, and compare the static and non-static functions to get an idea of how they should be used :)


[of course your final solution is fine too - the other functions are basically just a shorthand for that]