DrawRoundBoxStroke

Syntax

DrawRoundBoxStroke(x.d, y.d, Width.d, Height.d, RadiusX.d, RadiusY.d, Color.l, Opacity.f=1, NoRadiusDPIScaling.b=#False)

Description

Draws the outline (stroke) of a rectangle with rounded corners at the specified position and size using the given color and opacity. The roundness is defined by horizontal (RadiusX) and vertical (RadiusY) radii. The appearance of the stroke (width, dash style, caps, joins) is determined by the current stroke settings defined by DrawSetStroke().

Parameters

x.d
The horizontal coordinate of the rectangle's top-left corner in device-independent pixels (DIPs).

y.d
The vertical coordinate of the rectangle's top-left corner in DIPs.

Width.d
The width of the rectangle in DIPs.

Height.d
The height of the rectangle in DIPs.

RadiusX.d
The horizontal radius for the corners in DIPs. This value is clamped internally so it cannot exceed half the rectangle's width.

RadiusY.d
The vertical radius for the corners in DIPs. This value is clamped internally so it cannot exceed half the rectangle's height.

Color.l
The color of the stroke in RGB format (e.g., using RGB(r, g, b)).

Opacity.f (optional)
The opacity of the stroke, ranging from 0.0 (fully transparent) to 1.0 (fully opaque). Default is 1.0.

NoRadiusDPIScaling.b (optional)
If set to #True, the RadiusX and RadiusY values are treated as physical pixels and are not scaled by the current DPI. Default is #False (radii are treated as DIPs and scaled).

Return Value

This command does not return a value. It returns internally if Width, Height, or Opacity are zero or less.

Remarks

The coordinates, dimensions, and radii (unless NoRadiusDPIScaling is #True) are specified in DIPs but are converted internally to physical pixels based on the current output's DPI before drawing. The stroke is drawn using an internal solid color brush. Use DrawSetStroke() before calling this function to customize the line's appearance. If RadiusX or RadiusY are zero or negative, a standard rectangle outline (like DrawBoxStroke()) might be drawn.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

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

    ; Draw a simple rounded box outline (default 1px stroke)
    DrawRoundBoxStroke(20, 20, 150, 60, 15, 15, RGB(255, 0, 0))

    ; Set stroke to 4px wide, dashed
    DrawSetStroke(4, #PG_Stroke_Dash)
    ; Draw a thick dashed rounded box outline with 60% opacity
    DrawRoundBoxStroke(20, 100, 150, 80, 10, 30, RGB(0, 0, 255), 0.6)

    ; Restore default stroke
    DrawSetStroke(1)

EndProcedure

MyWindow = CreateWindow(0, 0, 200, 200, "DrawRoundBoxStroke 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, DrawRoundBox, DrawRoundBoxStrokeFill, DrawBoxStroke, BeginDraw, EndDraw

Supported OS

Windows, Linux