Code: Select all
; Vector Drawing Demo: Draw an endpoint on a partial circle
Enumeration image
#Base
#Final
EndEnumeration
Declare RenderProgressBar(void)
If CreateImage(#Base, 200, 200, 24, RGB(255,255,255))
If StartDrawing(ImageOutput(#Base))
For j=0 To 180 Step 20
For i=0 To 180 Step 20
Box(i,j,10,10,RGB(220,220,220))
Box(i+10,j+10,10,10,RGB(220,220,220))
Next
Next
Box(40,40,120,120,RGB(0,0,0))
Box(41,41,118,118,RGB(220,220,220))
Box(50,50,100,100,RGB(0,0,0))
Box(51,51,98,98,RGB(255,255,255))
StopDrawing()
EndIf
EndIf
If OpenWindow(0, 0, 0, 200, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CopyImage(#Base, #Final)
ImageGadget(0, 0, 0, 200, 200, ImageID(#Final))
tid = CreateThread(@RenderProgressBar(), 0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Procedure RenderProgressBar(void)
Delay(500)
progress.d = -90.0 ; To start at the top
While progress < 270.0
CopyImage(#Base, #Final)
If StartVectorDrawing(ImageVectorOutput(#Final))
VectorSourceLinearGradient(0,0,200,200)
VectorSourceGradientColor(RGBA(255, 0, 0, 255), 0.0)
VectorSourceGradientColor(RGBA(255, 255, 0, 255), 1.0)
; partial circle
AddPathCircle(100, 100, 90, -90, progress)
; Save needed values before clearing the path
angle.d = PathPointAngle(PathLength())+90
x.d=PathCursorX()
y.d=PathCursorY()
StrokePath(10)
; Draw endcap arrow using saved coordinates
If progress < 269
RotateCoordinates(x,y,angle)
MovePathCursor(x-10,y)
AddPathLine(x,y-20)
AddPathLine(x+10,y)
ClosePath()
FillPath()
EndIf
StopVectorDrawing()
progress + 0.1
EndIf
SetGadgetState(0, ImageID(#Final))
Delay(1)
Wend
Delay(200)
SetGadgetState(0, ImageID(#Base))
EndProcedure