I'm trying to rotate an image added to my canvas using KineticJS. I got it almost working. I know I need to set the offset to 'move' the rotation point, that part is working. But it is also moving to that location of the offset. After doing some rotating I can drag my image to another location in the canvas and continue rotating around its own center. I don't want to rotate the whole canvas, because I have multiple images on a layer.
The relevant code:
function rotateLayer() {
// Rotate bird image
var rotation = 15;
// Set rotation point:
imageDict[1].setOffsetX(imageDict[1].width() / 2);
imageDict[1].setOffsetY(imageDict[1].height() / 2);
// rotation in degrees
imageDict[1].rotate(rotation);
imageDict[1].getLayer().draw();
}
A working demo is on jsfiddle: http://jsfiddle.net/kp61vcfg/1/
So in short I want the rotation but not the movement.