Page 1 of 1

draw lines slow

Posted: Mon Oct 09, 2023 2:50 pm
by ludoke
How can I draw lines slow in a for next loop ,I try delay but this will not work

Re: draw lines slow

Posted: Mon Oct 09, 2023 2:57 pm
by RASHAD
Hi
Can you post a simple workable snippet ?

Re: draw lines slow

Posted: Mon Oct 09, 2023 4:00 pm
by Caronte3D
ludoke wrote: Mon Oct 09, 2023 2:50 pm ...I try delay but this will not work
Maybe you put the delay inside StartDrawing-StopDrawing

Re: draw lines slow

Posted: Tue Oct 10, 2023 8:17 am
by ludoke

Code: Select all

StartDrawing(CanvasOutput(#canvas1))      
            For n=7 To aantal_lijnen
               lijn$=GetGadgetItemText (#list1,n)  ;Gcode line ,coordinates lines ect..
               ;Debug lijn$
               ontrafel() ;find the start and end off the lines
             y2=180+(x_new *xpix_mm):x2=680+(zpix_mm * z_new );new endposition 
             LineXY(x1,y1,x2,y2,kleur) ;draw line            
             X1=X2:Y1=Y2     
             Delay(200);wait 200ms for drawing the next line ,this do not work
           Next  
           StopDrawing()
           

Re: draw lines slow

Posted: Tue Oct 10, 2023 8:41 am
by RASHAD
Hi
Workaround

Code: Select all

If OpenWindow(0, 0, 0, 600, 400, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 10, 10, 580, 350)
  ButtonGadget(1,10,360,60,20,"RUN")
  
  Repeat
    Select WaitWindowEvent(1)
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            For y = 10 To 200 Step 10
              StartDrawing(CanvasOutput(0))                
              LineXY(10,y,570,y,$0000FF)
              StopDrawing()
              Delay(500)
            Next
        EndSelect          
    EndSelect    
    
  Until Quit = 1
EndIf

Try

Code: Select all

For n=7 To aantal_lijnen
  lijn$=GetGadgetItemText (#list1,n)  ;Gcode line ,coordinates lines ect..
                                      ;Debug lijn$
  ontrafel()                          ;find the start and end off the lines
  y2=180+(x_new *xpix_mm):x2=680+(zpix_mm * z_new );new endposition
  StartDrawing(CanvasOutput(#canvas1)) 
    LineXY(x1,y1,x2,y2,kleur) ;draw line            
    X1=X2:Y1=Y2
  StopDrawing()     
  Delay(200);wait 200ms for drawing the next line ,this do not work
Next  

Re: draw lines slow

Posted: Tue Oct 10, 2023 9:40 am
by Fred
You can try to use a AddWindowTimer() for this

Re: draw lines slow

Posted: Tue Oct 10, 2023 9:42 am
by ludoke
thanks ,it works