DrawLineFill

Syntax

DrawLineFill(x1.d, y1.d, x2.d, y2.d, Brush)

Description

Draws a line between two points using the provided brush. The appearance of the line (width, dash style, caps) is determined by the current stroke settings defined by DrawSetStroke().

Parameters

x1.d
The horizontal coordinate of the line's starting point in device-independent pixels (DIPs).

y1.d
The vertical coordinate of the line's starting point in DIPs.

x2.d
The horizontal coordinate of the line's ending point in DIPs.

y2.d
The vertical coordinate of the line's ending point in DIPs.

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

Return Value

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

Remarks

The coordinates are specified in DIPs but are converted internally to physical pixels based on the current output's DPI before drawing. Use DrawSetStroke() before calling this function to customize the line's appearance. The appearance of the line depends on the brush type (image, gradient) and its properties (position, scale, rotation, extend mode, opacity).

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Create a gradient brush
Global GradientBrush = CreateBrushGradientLinear(0, 0, 200, 0, RGB(255, 0, 0), 1, RGB(0, 0, 255), 1) ; Red to Blue

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

    ; Set stroke to 10px wide
    DrawSetStroke(10)
    ; Draw a thick line using the gradient brush
    DrawLineFill(20, 50, 220, 50, GradientBrush)

    ; Restore default stroke
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 250, 100, "DrawLineFill 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

DrawLine, DrawSetStroke, CreateBrushImg, CreateBrushGradientLinear, BeginDraw, EndDraw

Supported OS

Windows, Linux