Thanks for any help.
Also, is the approach I am using reasonably efficient ? Although the code is already fast enough for me, I would be interested in possible optimizations.
EDIT: minor changes to the code for clarification
Code: Select all
UseJPEGImageDecoder()
CSize = 600
LoadImage(0, #PB_Compiler_Home + "\Examples\3D\Data\Textures\dirt.jpg")
ResizeImage(0,1000,1000)
OpenWindow(0, 0, 0, CSize, CSize, "Mask demo", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;
CreateImage(1, CSize , CSize, 32)
StartDrawing(ImageOutput(1))
Box(0,0,1000,1000,$FFFFFFFF)
Circle( 300,300,40, RGBA(255, 0, 255, 255))
Circle( 200,200,40, RGBA(255, 255, 0, 255))
Circle( 100,200,40, RGBA(0 , 0, 255, 255))
DrawAlphaImage(ImageID(0),25,25,230)
DrawingMode(#PB_2DDrawing_Outlined)
Circle( 300,300,40, RGBA(0,0,0, 255))
Circle( 200,200,40, RGBA(0,0,0, 255))
Circle( 100,200,40, RGBA(0,0,0, 255))
FillArea(0,0,0,0)
StopDrawing()
ImageGadget(0, 0, 0, CSize, CSize, ImageID(1))
AddWindowTimer(0, 1, 200)
Repeat
e = WaitWindowEvent()
Select e
Case #PB_Event_Timer
StartDrawing(ImageOutput(1))
newPositionX = Random(CSize)
newPositionY = Random(CSize)
newSize = Random(20)
Circle( newPositionX, newPositionY, newSize, RGBA(Random(255), Random(255), Random(255), 255))
; DrawAlphaImage(ImageID(0),25,25,200)
DrawingMode(#PB_2DDrawing_Outlined)
Circle( newPositionX, newPositionY, newSize, RGBA(0,0,0, 255))
FillArea(0,0,0,0)
StopDrawing()
SetGadgetState(0, ImageID(1))
Case #PB_Event_CloseWindow : End
EndSelect
ForEver