The provided example is a modified version of the IsInsidePath() example in the help, with added Translation & Scaling.
The mouse position gets adjusted and is visualized with a small circle.
Any suggestions?
Example:
Code: Select all
Procedure Draw()
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
If StartVectorDrawing(CanvasVectorOutput(0))
VectorSourceColor(RGBA(255, 255, 255, 255)) ; erase previous content
FillVectorOutput()
TranslateCoordinates(200, 100)
ScaleCoordinates(0.5,0.5)
x = (x - 200) / 0.5; caclulate new mouse position taking into account the translation & scale
y = (y - 100) / 0.5
AddPathCircle(0,0,100); prepare path
If IsInsidePath(x,y) ; check if the mouse is inside
VectorSourceColor(RGBA(0, 255, 0, 255))
Else
VectorSourceColor(RGBA(0, 0, 255, 255))
EndIf
FillPath()
VectorSourceColor($FF0000FF); draw mouse position
AddPathCircle(x,y,10)
FillPath()
StopVectorDrawing()
EndIf
EndProcedure
Procedure OnMouseMove()
Draw(); press the mouse button or nothing happens!
EndProcedure
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
LoadFont(0, "Times New Roman", 20, #PB_Font_Bold)
Draw()
BindGadgetEvent(0, @OnMouseMove(), #PB_EventType_MouseMove)
EndIf