VectorDrawing plus lent que 2DDrawing
Publié : mer. 21/oct./2015 13:32
Tout est dans le titre, voila un petit code de teste qui montrera de quoi je parle (chez mois 3X plus lent)
Code : Tout sélectionner
EnableExplicit
Enumeration
#MainForm
#MainArea
#MainCanvas
#BtWithVector
#BtWithDrawing
EndEnumeration
Global gCanvasW=2000,gCanvasH=2000,gGridSpace=10,gCurrentTime
Procedure VectorDrawing()
Protected X.d=gGridSpace
gCurrentTime=ElapsedMilliseconds()
StartVectorDrawing(CanvasVectorOutput(#MainCanvas))
; Eraze the canvas
VectorSourceColor($FBCDFAFF)
FillVectorOutput()
While X<gCanvasW
MovePathCursor(X,0)
AddPathLine(X,gCanvasH)
X+gGridSpace
Wend
VectorSourceColor($FB13458B)
DotPath(1,gGridSpace)
; DotPath(1,gGridSpace,#PB_Path_RoundEnd)
StopVectorDrawing()
Debug "Time ellapsed "+Str(ElapsedMilliseconds()-gCurrentTime)
EndProcedure
Procedure NormalDrawing()
Protected X=gGridSpace,Y=gGridSpace
gCurrentTime=ElapsedMilliseconds()
StartDrawing(CanvasOutput(#MainCanvas))
; Eraze the canvas
Box(0,0,gCanvasW,gCanvasH,$FBCDFAFF)
While X<gCanvasW
Y=gGridSpace
While Y<gCanvasH
Plot(X,Y,$FB13458B)
Y+gGridSpace
Wend
X+gGridSpace
Wend
StopDrawing()
Debug "Time ellapsed "+Str(ElapsedMilliseconds()-gCurrentTime)
EndProcedure
OpenWindow(0,0,0,800,600,"teste",#PB_Window_Maximize|#PB_Window_SystemMenu)
ButtonGadget(#BtWithVector,10,10,180,30,"Avec Vector")
BindGadgetEvent(#BtWithVector,@VectorDrawing())
ButtonGadget(#BtWithDrawing,200,10,180,30,"Avec 2D drawing")
BindGadgetEvent(#BtWithDrawing,@NormalDrawing())
ScrollAreaGadget(#MainArea,0,40,WindowWidth(#MainForm),WindowHeight(#MainForm),gCanvasW,gCanvasH)
CanvasGadget(#MainCanvas,0,0,gCanvasW,gCanvasH)
Repeat
If WaitWindowEvent()=#PB_Event_CloseWindow
End
EndIf
ForEver