#1 :
Code: Select all
Procedure Draw()
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
If StartVectorDrawing(CanvasVectorOutput(0))
AddPathCircle(300, 300, 250)
If IsInsidePath(x, y, #PB_Coordinate_Device)
If StartDrawing(CanvasOutput(0))
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
StopVectorDrawing()
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 600, 600, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 600, 600)
If StartVectorDrawing(CanvasVectorOutput(0))
AddPathCircle(300, 300, 250)
VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(2)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
draw()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
#2 :
Code: Select all
Procedure Draw()
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
If StartVectorDrawing(CanvasVectorOutput(0))
AddPathEllipse(200, 100, 150, 75)
If IsInsidePath(x, y, #PB_Coordinate_Device)
If StartDrawing(CanvasOutput(0))
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
StopVectorDrawing()
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
If StartVectorDrawing(CanvasVectorOutput(0))
AddPathEllipse(200, 100, 150, 75)
VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(2)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
draw()
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf