Rasovica
Rasovica

Reputation: 229

How to move rotation point of element in Javascript?

If i rotate image in EaselJS it rotates around 0,0 point how do i move it? Ty! Ras

Upvotes: 0

Views: 2788

Answers (2)

Chris Bowen - MSFT
Chris Bowen - MSFT

Reputation: 9849

Subclasses of DisplayObject (Bitmap, Text, Shape, etc.) support regX and regY properties, which let you change the registration point of the object from the default:

I've found this helpful not just for rotation, but other effects as well, such as controlling how a Bitmap flips when setting a negative scaleX/Y.

Best, Chris

Upvotes: 5

Bigger
Bigger

Reputation: 1970

You need to use translate(x,y) where x and y are the new rotation center you want.

Note: If you need to keep operating further, remember to un-translate it (translate again with same but negative values) after you are done with rotation, for this you will need to take into account how much you rotated it.

Upvotes: 3

Related Questions