marc_256 wrote: Wed Dec 13, 2023 9:41 am
at my tests Vectordrawing was aprox. 10x slower than 2D-Drawing
Same for my tests, I also use 2D-Drawing now.
What kind of comparison did both of you do?
The vector drawing library supports alpha-blending and anti aliasing for example. A fair comparison is therefore not easy.
When I compare DrawVectorText with DrawText, the vector version is faster.
When I compare AddPathCircle with Circle, the 2D drawing is faster, but only 2-3 times.
However, the factor is worse, when the drawing forms are smaller, because more aliasing has been performed compared to the total area of drawing.
So in fact, LineXY is much faster than AddPathLine, but look less pixel art.
Code: Select all
Enumeration
#Window
#Gadget1
#Gadget2
#Font
EndEnumeration
Define Time1.q, Time2.q
OpenWindow(#Window, 0, 0, 800, 400, "Vector vs. 2D Drawing", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CanvasGadget(#Gadget1, 0, 0, WindowWidth(#Window)/2, WindowHeight(#Window))
CanvasGadget(#Gadget2, WindowWidth(#Window)/2, 0, WindowWidth(#Window)/2, WindowHeight(#Window))
Define I.i
Define Loops = 10000
RandomSeed(1)
Time1 = ElapsedMilliseconds()
If StartVectorDrawing(CanvasVectorOutput(#Gadget1))
For I = 1 To Loops
VectorSourceColor($80000000|Random($FFFFFF))
AddPathCircle(Random(400), Random(400), Random(50))
FillPath()
Next
StopVectorDrawing()
EndIf
Time1 = ElapsedMilliseconds() - Time1
RandomSeed(1)
Time2 = ElapsedMilliseconds()
If StartDrawing(CanvasOutput(#Gadget2))
DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend)
For I = 1 To Loops
FrontColor($80000000|Random($FFFFFF))
Circle(Random(400), Random(400), Random(50))
Next
StopDrawing()
EndIf
Time2 = ElapsedMilliseconds() - Time2
SetClipboardText("Vector: "+Str(Time1)+" ms | 2D: "+Str(Time2)+" ms")
SetWindowTitle(#Window, "Vector: "+Str(Time1)+" ms | 2D: "+Str(Time2)+" ms")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Vector: 375 ms | 2D: 146 ms
Code: Select all
Enumeration
#Window
#Gadget1
#Gadget2
#Font
EndEnumeration
Define Time1.q, Time2.q
OpenWindow(#Window, 0, 0, 800, 400, "Vector vs. 2D Drawing", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CanvasGadget(#Gadget1, 0, 0, WindowWidth(#Window)/2, WindowHeight(#Window))
CanvasGadget(#Gadget2, WindowWidth(#Window)/2, 0, WindowWidth(#Window)/2, WindowHeight(#Window))
LoadFont(#Font, "Arial", 30)
Define I.i
Define Loops = 10000
RandomSeed(1)
Time1 = ElapsedMilliseconds()
If StartVectorDrawing(CanvasVectorOutput(#Gadget1))
VectorFont(FontID(#Font))
For I = 1 To Loops
VectorSourceColor($80000000|Random($FFFFFF))
MovePathCursor(Random(300), Random(380))
DrawVectorText("Hello World!")
Next
StopVectorDrawing()
EndIf
Time1 = ElapsedMilliseconds() - Time1
RandomSeed(1)
Time2 = ElapsedMilliseconds()
If StartDrawing(CanvasOutput(#Gadget2))
DrawingFont(FontID(#Font))
DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend)
For I = 1 To Loops
FrontColor($80000000|Random($FFFFFF))
DrawText(Random(300), Random(380), "Hello World!")
Next
StopDrawing()
EndIf
Time2 = ElapsedMilliseconds() - Time2
SetClipboardText("Vector: "+Str(Time1)+" ms | 2D: "+Str(Time2)+" ms")
SetWindowTitle(#Window, "Vector: "+Str(Time1)+" ms | 2D: "+Str(Time2)+" ms")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Vector: 415 ms | 2D: 1038 ms