I want to draw image on canvas rotated. with drawImage(image, 0, 0) I can draw image but how can I rotate that image for example 45 degrees and draw it, then dr
Well I have never used JavaFX, but browsing it's API documentation, I came up with this solution (I have not actually tried it so it may be wrong):
Canvas canvas = ...
Image img = ...
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.save(); // saves the current state on stack, including the current transform
gc.rotate(45);
gc.drawImage(img);
gc.restore(); // back to original state (before rotation)
gc.save();
gc.rotate(-50);
gc.drawImage(img);
gc.restore();
I don't know if it works here, but the idea (transformation stack) is borrowed from other drawing API (like OpenGL).