DrawGetStroke

Syntax

Width.f = DrawGetStroke(*Flags.Integer=#Null, *DashStartOffset.Float=#Null)

Description

Retrieves the current settings for drawing strokes (lines and outlines), including the stroke width, flags (dash style, caps, joins), and dash offset.

Parameters

*Flags.Integer (optional)
A pointer to an integer variable that will receive the current stroke flags. If #Null, the flags are not returned.

*DashStartOffset.Float (optional)
A pointer to a float variable that will receive the current dash start offset (used for animating dashed lines). If #Null, the offset is not returned.

Return Value

Returns the current stroke width in device-independent pixels (DIPs) as a floating-point number. Returns 0.0 or #False if called outside a BeginDraw() / EndDraw() block.

The returned *Flags value will be a combination of the following constants (defined in DrawSetStroke documentation):

#PG_Stroke_Dash, #PG_Stroke_Dot, #PG_Stroke_CustomDash, #PG_Stroke_NoDPIScaling, #PG_Stroke_RoundEnd, #PG_Stroke_SquareEnd, #PG_Stroke_RoundCorner, #PG_Stroke_BevelCorner, #PG_Stroke_Center, #PG_Stroke_Outside

Remarks

This function allows querying the current stroke settings, which might have been changed using DrawSetStroke() or related functions. The returned width is in DIPs.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

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

    CurrentWidth.f = DrawGetStroke(@CurrentFlags, @CurrentOffset.f)
    Debug "Initial Stroke - Width: " + StrF(CurrentWidth) + ", Flags: " + CurrentFlags + ", Offset: " + StrF(CurrentOffset)

    ; Change stroke settings
    DrawSetStroke(5, #PG_Stroke_Dash | #PG_Stroke_RoundCorner, 2.5)

    CurrentWidth.f = DrawGetStroke(@CurrentFlags, @CurrentOffset.f)
    Debug "Changed Stroke - Width: " + StrF(CurrentWidth) + ", Flags: " + CurrentFlags + ", Offset: " + StrF(CurrentOffset)

    ; Draw using the new stroke
    DrawBoxStroke(50, 50, 100, 50, RGB(0,0,255))

    ; Restore default
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 200, 150, "Get Stroke 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

DrawSetStroke, DrawSetStrokeCustom, DrawSetStrokeMiterLimit, BeginDraw, EndDraw

Supported OS

Windows, Linux