Rotate an image in a scaled context
- by nathan
Here is my working piece of code to rotate an image toward a point (in my case, the mouse cursor).
float dx = newx - ploc.x;
float dy = newy - ploc.y;
float angle = (float) Math.toDegrees(Math.atan2(dy, dx));
Where ploc is the location of the image i'm rotating.
And here is the rendering code:
g.rotate(loc.x + width / 2, loc.y + height / 2,…