what actually does automidhandle true do
BlitzMax Forums/BlitzMax Beginners Area/what actually does automidhandle true do
| ||
I always though if this was on the image would be drawn from the midpoint of that image, no i am guessing when i use the setscale this if then messing things up here is what i haveGraphics game.DeskWidth, game.DeskHeight, 0 AutoMidHandle True Global ring:TImage = CreateImage(80, 80, FILTEREDIMAGE) Cls SetColor 20, 255, 100 DrawOval 40, 40, 40, 40 SetColor 0, 0, 0 DrawOval 42, 42, 36, 36 SetColor 255, 255, 255 GrabImage(ring, 0, 0) Repeat Cls If KeyHit(KEY_Z) Then Tring.Create() Tring.update() Tring.draw() Flip Until KeyHit(KEY_ESCAPE) End Type Tring Field sc:Float, de Global ringlist:TList = New TList Function Create() r:Tring = New Tring r.sc = 0.1 ringlist.addlast r End Function Function update() For r:Tring = EachIn ringlist r.sc = r.sc * 1.05 Next End Function Function draw() Local co = 0 For r:Tring = EachIn ringlist co = co + 1 SetScale 1, 1 Local dx = game.DeskWidth / 2 Local dy = game.DeskHeight / 2 SetScale r.sc, r.sc SetAlpha 1 SetColor 255, 200, 50 DrawImage ring, dx, dy Next SetScale 1, 1 SetColor 255, 255, 255 DrawText "count of rings= " + co, 10, 60 End Function End Type Type game Global deskwidth:Int = 1024 Global deskheight:Int = 768 End Type i am trying to get the rings to come straight forward towards viewer dead center....what am i doing wrong any ideas...... |
| ||
AutoMidHandle True: sets the point for rotate at center (x,y) instead of the upper left corner. When you draw, its origin is still at the upper left corner of the image. You will need to accommodate for the center x,y yourself by centerx = image.width/2 and centery = image.height/2 Hope this helps :) |
| ||
AutoMidHandle is doing what you expect but DrawOval is not. Note that the arguments to DrawRect specify a location for one corner and also width and height. DrawOval, contrary to what you might expect, is exactly the same. The oval fits into the rectangle that would be drawn with DrawRect. |
| ||
does imagewidth(image:timage) return the actual scaled value of the image as it is at that point or the original imagewidth |
| ||
fixed itGraphics game.DeskWidth, game.DeskHeight, 0 AutoMidHandle True Global ring:TImage = CreateImage(80, 80, FILTEREDIMAGE) Cls SetColor 20, 255, 100 DrawOval 40, 40, 40, 40 SetColor 0, 0, 0 DrawOval 42, 42, 36, 36 SetColor 255, 255, 255 GrabImage(ring, 0, 0) Repeat Cls If KeyHit(KEY_Z) Then Tring.Create() Tring.update() Tring.draw() Flip Until KeyHit(KEY_ESCAPE) End Type Tring Field sc:Float, de Global ringlist:TList = New TList Function Create() r:Tring = New Tring r.sc = 0.1 ringlist.addlast r End Function Function update() For r:Tring = EachIn ringlist r.sc = r.sc * 1.05 Next End Function Function draw() Local co = 0 For r:Tring = EachIn ringlist co = co + 1 Local dx = game.DeskWidth / 2 Local dy = game.DeskHeight / 2 SetScale r.sc, r.sc SetAlpha 1 SetColor 255, 200, 50 DrawImage ring, dx - (ImageWidth(ring) * r.sc) / 4, dy - (ImageHeight(ring) * r.sc) / 4 Next SetScale 1, 1 SetColor 255, 255, 255 DrawText "count of rings= " + co, 10, 60 End Function End Type Type game Global deskwidth:Int = 1024 Global deskheight:Int = 768 End Type thanks........ |
| ||
Hi, the 1st version of your code worked well, but maybe you misunderstood how does DRAWOVAL work, since it draws the oval starting from the upper-left corner of its ideal bounding rectangle and not from iots center... I made a couple of changes and also added a line to remove rings when they beacome no more visible (you know, for preventing the program becoming too slow) Graphics game.DeskWidth, game.DeskHeight, 0 AutoMidHandle True Global ring:TImage = CreateImage(80, 80, FILTEREDIMAGE) Cls SetColor 20, 255, 100 DrawOval 0, 0, 80, 80 '<----- Line modified SetColor 0, 0, 0 DrawOval 2, 2, 76, 76 '<----- Line modified SetColor 255, 255, 255 GrabImage(ring, 0, 0) Repeat Cls If KeyHit(KEY_Z) Then Tring.Create() Tring.update() Tring.draw() Flip Until KeyHit(KEY_ESCAPE) End Type Tring Field sc:Float, de Global ringlist:TList = New TList Function Create() r:Tring = New Tring r.sc = 0.1 ringlist.addlast r End Function Function update() For r:Tring = EachIn ringlist r.sc = r.sc * 1.05 If r.sc>15 ListRemove(ringlist, r);co:-1 '<----- Line added Next End Function Function draw() Local co = 0 For r:Tring = EachIn ringlist co = co + 1 SetScale 1, 1 Local dx = game.DeskWidth / 2 Local dy = game.DeskHeight / 2 SetScale r.sc, r.sc SetAlpha 1 SetColor 255, 200, 50 DrawImage ring, dx, dy Next SetScale 1, 1 SetColor 255, 255, 255 DrawText "count of rings= "+co, 10, 60 End Function End Type Type game Global deskwidth:Int = 1024 Global deskheight:Int = 768 End Type |
| ||
i see what you mean i didnt get thats what it was doing thanks for clearing it up. makes more sense now.... Thanks again Ian |
| ||
Just to clarify, AutoMidHandle True will centre the handle of images which are subsequently loaded. It does not affect the handle of images that you've loaded already. |