Delay stops the whole program, so if you want to use it, you'll have to set it after the complete image has been generated.
(so
not between StartDrawing and StopDrawing)
Code: Select all
OpenWindow(0, 200, 100, 1000, 600, " timer test")
CreateImage(0, DesktopScaledX(1000), DesktopScaledY(600))
ImageGadget(0, 0, 0, 0, 0, ImageID(0))
Repeat
; 1. Tracing the image
StartDrawing(ImageOutput(0))
Circle(Random(1000, 0), Random(600, 0), 50, RGB(0,0,255))
StopDrawing()
; 2. Assign image to object
SetGadgetState(0, ImageID(0))
; 3. Wait
Delay(1000)
Until WaitWindowEvent = #PB_Event_CloseWindow

But a timer is better, as the rest of the program can continue.
Code: Select all
OpenWindow(0, 200, 100, 1000, 600, " timer test")
AddWindowTimer(0, 1, 1000)
CreateImage(0, DesktopScaledX(1000), DesktopScaledY(600))
ImageGadget(0, 0, 0, 0, 0, ImageID(0))
Procedure Draw_Image()
; 1. Tracing the image
StartDrawing(ImageOutput(0))
Circle(Random(1000, 0), Random(600, 0), 50, RGB(0,0,255))
StopDrawing()
; 2. Assign image to object
SetGadgetState(0, ImageID(0))
EndProcedure
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
If EventTimer() = 1 : Draw_Image() : EndIf
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
In this example, the mouse cursor shows that the program is available for other actions