DrawPathFill

Syntax

DrawPathFill(Brush, Flags=#Null)

Description

Fills the shape defined by the current path using the specified brush (image or gradient). The path must define a closed shape (implicitly or explicitly via PathClose()) for the fill to be meaningful.

Parameters

Brush
The handle of the brush (created with CreateBrushImg(), CreateBrushGradientLinear(), etc.) used to fill the path.

Flags (optional)
Flags modifying the behavior:

#PG_Path_Preserve : Keeps the path geometry defined after this drawing command is executed. Without this flag, the path is consumed and reset.
#PG_Path_Winding  : Uses the winding fill mode to determine which areas are inside the path (useful for complex self-intersecting paths). Default is alternate fill mode.

Return Value

This command does not return a value. It returns internally if the Brush handle is invalid or the path is empty.

Remarks

This function must be called between BeginDraw() and EndDraw(), after defining a path using commands like PathMoveTo(), PathAddLine(), etc. The appearance of the fill depends on the brush type and its properties (position, scale, rotation, extend mode, opacity). By default, the path geometry is cleared after drawing; use #PG_Path_Preserve if you need to draw the same path again (e.g., stroke it afterwards).

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Create a gradient brush
Global GradientBrush = CreateBrushGradientLinear(0, 10, 0, 150, RGB(255, 255, 0), 1, RGB(255, 100, 0), 1) ; Yellow to Orange

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

    ; Define a path (e.g., a simple house shape)
    PathMoveTo(50, 150)
    PathAddLine(50, 80)
    PathAddLine(125, 20) ; Roof peak
    PathAddLine(200, 80)
    PathAddLine(200, 150)
    PathClose()

    ; Fill the path with the gradient brush
    DrawPathFill(GradientBrush, #PG_Path_Preserve) ; Preserve path for stroke

    ; Stroke the path
    DrawSetStroke(2)
    DrawPathStroke(RGB(100, 50, 0)) ; Brown outline
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 250, 200, "DrawPathFill Example")

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

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

FreeBrush(GradientBrush)
StopProGUI()

See Also

DrawPath, DrawPathStroke, CreateBrushImg, CreateBrushGradientLinear, CreateBrushGradientRadial, PathMoveTo, PathAddLine, PathClose, BeginDraw, EndDraw

Supported OS

Windows (Direct2D only), Linux (Cairo only)