draw lines slow

Just starting out? Need help? Post your questions and find answers here.
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

draw lines slow

Post by ludoke »

How can I draw lines slow in a for next loop ,I try delay but this will not work
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: draw lines slow

Post by RASHAD »

Hi
Can you post a simple workable snippet ?
Egypt my love
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: draw lines slow

Post 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
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

Re: draw lines slow

Post 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()
           
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: draw lines slow

Post 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  
Egypt my love
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: draw lines slow

Post by Fred »

You can try to use a AddWindowTimer() for this
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

Re: draw lines slow

Post by ludoke »

thanks ,it works
Post Reply