Mid-Handle for Drawing Ovals?
BlitzMax Forums/BlitzMax Beginners Area/Mid-Handle for Drawing Ovals?
| ||
I'm looking for a quick/easy way to AutoMidHandle my ovals. AutoMidHandle is only for images I guess, and SetOrigin or SetHandle are based on screen coordinates. I could calculate the middle-point of the ovals using screen coordinates and size of the oval, but that seems a little over the top. Any ideas?Graphics 800,600 AutoMidHandle(enable)'only works for images? While Not KeyHit(key_escape) DrawOval(100,100,10,10) DrawOval(100,200,40,40) Flip Wend Edit: I will be using images for this anyway, but would like to know a way of doing this without them. |
| ||
Why is it over the top? All you need to do is subtract half of the width/height from the x/y co-ordinates where you want the centre of the oval to be. So for the example above...DrawOval 95,95,10,10 DrawOval 80,180,40,40 |
| ||
a bit nicer way:Graphics 800,600,0,-1 Global Rot:Int = 0 While Not KeyHit(key_escape) SetRotation rot SetHandle(5,10) ' this is the right to make a midhandlebeviour, don't mess it up with SetOrigin ' which only changes the offset DrawOval(100,100,10,20) SetHandle(20,40) DrawOval(100,200,40,80) SetHandle(0,0) SetRotation 0 DrawText "Rotation : " + Rot,20,20 If KeyDown(Key_F1) Then Rot:+3 Flip Cls Wend |
| ||
Nice! Thanks to both of you, JazzieB and klepto2. |