Page 1 of 1

Box draw coordinates bug?

Posted: Sun Nov 29, 2015 4:08 pm
by Juan Carlos
Drawing a box and give the coordinates x, y instead of draw the box in the correct coordinates, the box is drawed in a different place, it is a bug? here is the example:

Code: Select all

@DISPLAY {Title="Example Box Test Position", Width=800, Height=600}

SetFont(#SANS, 25)
SetFontColor(#WHITE)
TextOut(200, 60, "The Box has the postion 150 and 100.")
TextOut(200, 100, "The text has the postion 150 and 100.")
SetFillStyle(#FILLCOLOR)
SetFontColor(#WHITE)
SetFontStyle(#EDGE, #BLACK, 2)
Box(150, 100, 64, 30, $8080ff, {AnchorX = 0.5, AnchorY = 0.5, RoundLevel = 10, Hidden = True })
TextOut(150, 100, "OFF")

TextOut(#CENTER, 300, "In both case the origin are the same, but its position in the screeen not.")

/*** Posición Puntero de ratón para obtener coordenadas ***/
Function p_CheckRaton()
;Para obtener la posición del ratón.
Ratonx=MouseX()
Ratony=MouseY()
SetFont(#SANS, 16)
SetFontColor(#WHITE)
SetFontStyle(#ANTIALIAS)  
SetFillStyle(#FILLCOLOR)
Box(8, 10, 116, 16, #BLACK)
TextOut(10, 10, "Ratón: "..Ratonx.." / "..Ratony)
EndFunction
SetInterval(10, p_CheckRaton, 25) ;Para Activa/desactivar el chequeo ratón.

EscapeQuit(True)
Repeat
  WaitEvent
Forever

I added that show the mouse coordinates to example to see the problem.

Re: Box draw coordinates bug?

Posted: Mon Nov 30, 2015 5:38 pm
by airsoftsoftwair
No, it's not a bug. The (x,y) coordinates are relative to the anchor point. Since you've set the anchor point to (0.5,0.5) the box will be drawn at (x-width*anchorx,y-height*anchory). If you want the box's top-left edge to appear exactly at (150,100) you need to set the anchor point to (0,0) which is also the default, i.e. just use

Code: Select all

Box(150, 100, 64, 30, $8080ff, {RoundLevel = 10, Hidden = True })

Re: Box draw coordinates bug?

Posted: Tue Dec 01, 2015 12:55 pm
by Juan Carlos
Thanks Andreas.