Rotate by point (left down corner)

61 Views Asked by At

How do rotate by point in Bitmap? I need rotate hande by left down corner.

tweenjs, easeljs

enter image description here

THX.

2

There are 2 best solutions below

0
Lanny On

Rotation uses the registration point (top-left for Bitmaps by default), but you can also set regX and regY to change where the origin of the element is.

0
cristiancajiaos On

You can use the regX and regY properties of the Bitmap object to change the offset of the registration point of it.

For purposes of your question: If you want to use the left down corner, the coordinates you need to specify are (0, imgHeight), where imgHeight is the height of your image used to create your Bitmap.

hand.regX = 0;
hand.regY = imgHeight;

In the case of the value for the regY property, you can assign it manually, or you can also use the getTransformedBounds() method to get the height.

var handRect = hand.getTransformedBounds();
hand.regY = handRect.height;