Difficult to describe problem with CanvasGadget
Posted: Mon Jun 23, 2014 11:26 am
Very strange (if Debugger = Off):
Why the rectangle stops with blinking (or blinking slow or flickers only) some times? As long as I move the mouse cursor, blinking is correct with a delay of 500 ms.
But If I turn on the Debugger (and print the word "Update" every 500 ms) then it works without problems!
Why the rectangle stops with blinking (or blinking slow or flickers only) some times? As long as I move the mouse cursor, blinking is correct with a delay of 500 ms.
But If I turn on the Debugger (and print the word "Update" every 500 ms) then it works without problems!
Code: Select all
#Window = 0
#GadgetCanvas = 1
#Timer = 1
Global col1 = $0000FF
Global col2 = $FFFFFF
OpenWindow(#Window, 0, 0, 800, 600, "Test", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
SmartWindowRefresh(#Window, 1)
CanvasGadget(#GadgetCanvas, 10, 10, 640, 480)
AddWindowTimer(#Window, #Timer, 500)
CreateImage(0, 320, 240, 24, $000000)
StartDrawing(ImageOutput(0))
For i = 0 To 239
Line(0, i, 320, 1, RGB(i,i,i))
Next i
StopDrawing()
Procedure UpdateCanvas()
Debug "Update"
CopyImage(0,1)
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_Outlined)
Box(10,10,100,100,col1)
StopDrawing()
Swap col1, col2
ResizeImage(1, 320 * 2, 240 * 2, #PB_Image_Raw)
SetGadgetAttribute(#GadgetCanvas, #PB_Canvas_Image, ImageID(1))
EndProcedure
Repeat
Event = WaitWindowEvent(10)
Select Event
Case #PB_Event_Timer: If EventTimer() = #Timer: UpdateCanvas(): EndIf
EndSelect
Until Event = #PB_Event_CloseWindow