Jump to content

  • Log In with Google      Sign In   
  • Create Account


FriesBoury

Member Since 28 Sep 2012
Offline Last Active Oct 12 2012 04:48 PM

#4986847 Rotating an object within a box

Posted by FriesBoury on 04 October 2012 - 01:19 PM

I'm not sure how it works in the environment you are programming in, but almost always, an image gets drawn beginning from the top left corner.
Therefore the first transformation you do, will use this corner as an "anchorpoint".

Before you do the rotation, try to move your image so the center of your image matches the (0,0) coordinates. Not the top left corner.

so your transformations should be:
- 1: translation with offset(-imageWidth/2, -imageHeight/2)
- 2 and 3: rotation and scale (both don't affect position of anchorpoint, so order doesn't really matter here)
- 4: translation to match image center with frame center (frameWidth/2, frameHeight/2)

I hope this was useful to you.


PARTNERS