How to center rotation (midhandle) a rect or oval?
BlitzMax Forums/BlitzMax Programming/How to center rotation (midhandle) a rect or oval?
| ||
Using a image with midhandle works great. But for the sake of examples it is nice to use the basic drawing commands along with SetRotation(). But somehow the rect is rotated around its top,left corner. I need a function to in every case recalculate the rotation and movement as if the rect was midhandled so I can use the same SetRotaion() command as for a midhandled image. I figured it was as simple as moving it in X,Y with Cos,Sin.. But I guess not.. |
| ||
Well, I think the simpliest way is to save the Rect or Oval in an Image. Maybe like this Press Space to toggle between Midhandle and use A and Y to Rotate |
| ||
Many Thanks! That works perfect. |
| ||
You can also do something like thisLocal RectXPos = 100 Local RectYPos = 100 Local RectWidth = 10 Local RectHeight = 10 DrawRect (RectXPos-RectWidth/2,RectYPos-RectHeight/2,RectWidth,RectHeight) ETA: Then again. after testing, that doesn't seem to work. |
| ||
SetHandle |
| ||
Yes, never seen this command before, but it really works by using SetHandle w/2,h/2. Thx. |
| ||
Good news, SetHandle.. SetRotation(Rot) SetHandle w/2, h/2 DrawOval( 400-w/2 , 300-h/2, w, h ) |
| ||
Didn't AutoMidHandle do this at one point, or did I just imagine it? |
| ||
Seems that's only for images although I can't remember if it included draws at an earlier level. |