PathClose

Syntax

PathClose()

Description

Closes the current figure in the path by adding a straight line segment from the current point back to the starting point of the figure (the point specified in the last PathMoveTo() call).

Parameters

This command takes no parameters.

Return Value

This command does not return a value.

Remarks

This function must be called after at least one path drawing command (PathAddLine(), PathAddCurve(), PathAddArc()) has been issued since the last PathMoveTo(). Closing a path is essential for creating filled shapes correctly. After closing, the current path point is moved back to the figure's starting point. If the path already ends at the start point, this command effectively does nothing visually but still marks the figure as closed.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
  
    DrawClear(RGB(255, 255, 255), 1)

    ; Draw a thick blue stroke for the path
    DrawSetStroke(3)

    ; Define a triangle path
    PathMoveTo(50, 150)  ; Start point
    PathAddLine(150, 50) ; Line to top vertex
    PathAddLine(250, 150) ; Line to right vertex
    PathClose()          ; Line back to start point (50, 150)

    ; Fill the closed path with red
    RedBrush = CreateBrushImg(CreateImg(1,1,RGBA(255,0,0,255)))
    DrawPathFill(RedBrush)
    FreeBrush(RedBrush)

    ; Draw the path outline (optional, path still exists if #PG_Path_Preserve was used)
    ; DrawPathStroke(RGB(0, 0, 255)) ; Path was consumed by DrawPathFill without #PG_Path_Preserve

    ; Restore default stroke
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 300, 200, "PathClose Example")

If MyWindow
  AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

PathMoveTo, PathAddLine, PathAddCurve, PathAddArc, PathReset, DrawPath, DrawPathStroke, DrawPathFill

Supported OS

Windows (Direct2D only), Linux (Cairo only)