slow drawing

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: slow drawing

Post by netmaestro »

wilbert wrote:it's a bit strange because the VectorDrawing library and this gdrawing.pbi file both seem to use GDI+
I had the same thought but I didn't express it because at the time I had icing all over my fingers.
BERESHEIT
Olli
Addict
Addict
Posts: 1281
Joined: Wed May 27, 2020 12:26 pm

Re: slow drawing

Post by Olli »

I agree too, but GDI+, exactly as Scintilla in the past, has an internal feature which asks anything in the network.
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

Re: slow drawing

Post by ludoke »

I don't know if it is slower or faster, but Danilo's examples are a big help.
I still have so much to discover and learn.
Olli
Addict
Addict
Posts: 1281
Joined: Wed May 27, 2020 12:26 pm

Re: slow drawing

Post by Olli »

Personnally, I just made a remover of the native Norton anti-virus installer... And GDI strangely lost this surprising latency.
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

Re: slow drawing comparing

Post by ludoke »

addpathline and AddPathCircle are the slowest.
The time is changeable ?
discovered some more,it is strange that drawing a circle seems faster than drawing a line

Code: Select all

OpenWindow(0,0,0,1800,900,"")
CanvasGadget(0, 0,0,1800,900)
    x.d = 500
    y.d =400
start.q = ElapsedMilliseconds()
;speedtest drawing arc 
StartVectorDrawing(CanvasVectorOutput(0))
  For i=1 To 25000
    x=400:y=300:a=100:b=200
    MovePathCursor(x,y)
   ; AddPathLine(a,b);613ms
    AddPathCircle(400,300,100,0,330);2789ms 
    VectorSourceColor(0)
    StrokePath(2)
  Next
StopVectorDrawing()
finish.q = ElapsedMilliseconds()
MessageRequester("Time Taken for 25K lines drawn:", Str(finish-start))
;-------------------------------------------------------------------------
;speedtest  with linxy
start.q = ElapsedMilliseconds()
StartDrawing(CanvasOutput(0))
  For i=1 To 25000  
    x=400:y=300:a=100:b=200 ;46ms
    LineXY(x,y,a,b,0)
  Next
StopDrawing()
finish.q = ElapsedMilliseconds()
MessageRequester("Time Taken for 25K lines drawn:", Str(finish-start))
;--------------------------------------------------------------------------
;speedtest for arcs with linexy
x_old.d=0
y_old.d=0
x1.d=0:y1.d=0
start.q = ElapsedMilliseconds()
StartDrawing(CanvasOutput(0))
LineXY(100,100,1000,100,0)
    
    radius=200
    start_arc=0: arc=start_arc:end_arc=290 
       x1=Cos(Radian(arc))*radius
       y1=-Sin(Radian(arc))*radius  ;negative for the quadrant
       x_old=x1:y_old=y1
     For i=1 To 25000  ; arcs =4 to 18ms  time is changeable ?
     While arc <=end_arc     
       x1=Cos(Radian(arc))*radius
       y1=-Sin(Radian(arc))*radius  
       LineXY(x+x_old,y+y_old,x+x1,y+y1,0)
       x_old=x1:y_old=y1:arc=arc+1
      Wend
     Next
StopDrawing()
finish.q = ElapsedMilliseconds()
MessageRequester("Time Taken for 25K lines drawn:", Str(finish-start))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: slow drawing

Post by Saki »

Hi,
but for your application it should really be fast enough.
What do you want to do with many thousands of lines and circles in a split second ?

There are beautiful benchmark programs, check them out and have fun :wink:

Best Regards Saki
地球上の平和
ludoke
Enthusiast
Enthusiast
Posts: 155
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

Re: slow drawing

Post by ludoke »

Saki,
I try to make a gcode viewer,a gcode file can contain hundreds of thousands of lines.
I would like such a file on the screen so I can rotate it, zoom, move. But I still have a lot to discover.
I'm also trying to find something to do this in 3D.
User avatar
Demivec
Addict
Addict
Posts: 4283
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: slow drawing

Post by Demivec »

ludoke wrote:Saki,
I try to make a gcode viewer,a gcode file can contain hundreds of thousands of lines.
I would like such a file on the screen so I can rotate it, zoom, move. But I still have a lot to discover.
I'm also trying to find something to do this in 3D.
Are you planning to convert/interpret the gcode into data for the rendering and then store this separately so that only the rendering data has to be used for rotations, zooming, etc without the need to keep referencing the gcode for each rendering?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: slow drawing

Post by srod »

ludoke wrote:Saki,
I try to make a gcode viewer,a gcode file can contain hundreds of thousands of lines.
I would like such a file on the screen so I can rotate it, zoom, move. But I still have a lot to discover.
I'm also trying to find something to do this in 3D.
It's probably no coincidence that most gcode viewers use OpenGL, or some such, for this kind og thing, although this could be for cross-platform reasons if nothing else. If you are showing toolpaths and the like then you would likely wish to throw up different orientations and, well, I wouldn't have thought that the vector library would be the way to go. Just depends how far you need to go down this path?
I may look like a mule, but I'm not a complete ass.
Post Reply