DrawRoundBoxFill

Syntax

DrawRoundBoxFill(x.d, y.d, Width.d, Height.d, RadiusX.d, RadiusY.d, Brush, NoRadiusDPIScaling.b=#False)

Description

Draws a filled rectangle with rounded corners at the specified position and size using the provided brush. The roundness is defined by horizontal (RadiusX) and vertical (RadiusY) radii.

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.

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

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 the Brush handle is invalid, or if Width or Height 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 appearance of the fill depends on the brush type (image, gradient) and its properties (position, scale, rotation, extend mode, opacity). If RadiusX or RadiusY are zero or negative, a standard rectangle (like DrawBoxFill()) might be drawn.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Create a gradient brush
Global GradientBrush = CreateBrushGradientLinear(0, 0, 150, 0, RGB(0, 255, 0), 1, RGB(0, 100, 255), 1) ; Green to Blue

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

    ; Draw a rounded box filled with the gradient
    DrawRoundBoxFill(20, 20, 200, 100, 25, 25, GradientBrush)

EndProcedure

MyWindow = CreateWindow(0, 0, 240, 140, "DrawRoundBoxFill 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

DrawRoundBox, DrawRoundBoxStrokeFill, DrawBoxFill, CreateBrushImg, CreateBrushGradientLinear, BeginDraw, EndDraw

Supported OS

Windows, Linux