Box draw coordinates bug?

Report any Hollywood bugs here
Post Reply
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Box draw coordinates bug?

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Box draw coordinates bug?

Post 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 })
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: Box draw coordinates bug?

Post by Juan Carlos »

Thanks Andreas.
Post Reply