drawRectFilled
Draws a solid, filled rectangle between two defined points on the screen or canvas.
Signature
Section titled “Signature”ui.drawRectFilled(p1, p2, color, rounding, roundingFlags)Description
Section titled “Description”This function renders a filled rectangle. The shape is defined by an axis-aligned bounding box calculated from points p1 (usually top-left) and p2 (usually bottom-right).
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
p1 | vec2 | Yes | - | Screen coordinates for the first corner. |
p2 | vec2 | Yes | - | Screen coordinates for the opposite corner. |
color | rgbm | Yes | - | The fill color and opacity. |
rounding | number | No | 0.0 | The radius of the corners in pixels. |
roundingFlags | ui.CornerFlags | No | All | Bitmask determining which corners are rounded. |
Return Values
Section titled “Return Values”- None
Examples
Section titled “Examples”Draw a semi-transparent black background box.
local p1 = vec2(0, 0)local p2 = vec2(200, 100)local black = rgbm(0, 0, 0, 0.5)
-- black with 50% opacityui.drawRectFilled(p1, p2, black)Draw a filled green shape with fully rounded corners (pill shape).
local p1 = vec2(50, 50)local p2 = vec2(150, 90)local green = rgbm(0, 1, 0, 1)local radius = 20
-- radius of 20px for smooth cornersui.drawRectFilled(p1, p2, green, radius)