I do not know if this is possible or stupid, but it would be nice to be able to define separately before a VectorSourceColor () and VectorSourceImage () loop, without having to redefine at each iteration to use, while they are always the same. This is to avoid an unnecessary slowdown.
Code: Select all
If OpenWindow(0, 0, 0, 1500, 1000, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 1500, 1000)
LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")
If StartVectorDrawing(CanvasVectorOutput(0))
t=ElapsedMilliseconds()
For i = 1 To 10000
MovePathCursor(Random(1500), Random(1000))
AddPathLine(Random(1500), Random(1000))
VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(2)
x = Random(1500) : y = Random(1000)
AddPathBox(x, y, ImageWidth(0), ImageHeight(0))
TranslateCoordinates(x, y)
VectorSourceImage(ImageID(0), 255, ImageWidth(0), ImageHeight(0))
FillPath()
TranslateCoordinates(-x, -y)
Next i
Debug ElapsedMilliseconds()-t
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Code: Select all
If OpenWindow(0, 0, 0, 1500, 1000, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 1500, 1000)
LoadImage(0, #PB_Compiler_Home + "examples/Sources/Data/PureBasicLogo.bmp")
If StartVectorDrawing(CanvasVectorOutput(0))
VectorSourceColor(RGBA(255, 0, 0, 255))
VectorSourceImage(ImageID(0), 255, ImageWidth(0), ImageHeight(0))
t=ElapsedMilliseconds()
For i = 1 To 10000
MovePathCursor(Random(1500), Random(1000))
AddPathLine(Random(1500), Random(1000))
StrokePath(2,#Pb_VectorColor) <--------------------------------------
x = Random(1500) : y = Random(1000)
AddPathBox(x, y, ImageWidth(0), ImageHeight(0))
TranslateCoordinates(x, y)
FillPath(#Pb_VectorImage) <--------------------------------------
TranslateCoordinates(-x, -y)
Next i
Debug ElapsedMilliseconds()-t
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf