drawRect
Draws an unfilled rectangle outline between two defined points on the screen or canvas.
Signature
Section titled “Signature”ui.drawRect(p1, p2, color, rounding, roundingFlags, thickness)Description
Section titled “Description”This function renders a hollow 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 of the rectangle. |
p2 | vec2 | Yes | - | Screen coordinates for the opposite corner of the rectangle. |
color | rgbm | Yes | - | The color and opacity of the outline. |
rounding | number | No | 0.0 | The radius of the corners in pixels. |
roundingFlags | ui.CornerFlags | No | ui.CornerFlags.All | Bitmask determining which corners apply the rounding radius. |
thickness | number | No | 1.0 | The width of the outline stroke in pixels. |
Return Values
Section titled “Return Values”- None
Examples
Section titled “Examples”Draw a simple red box with default thickness and sharp corners.
local startPos = vec2(10, 10)local endPos = vec2(100, 50)local red = (1, 0, 0, 1)
-- draw a red rectangleui.drawRect(startPos, endPos, red)Draw a thick blue box where only the top two corners are rounded.
local p1 = vec2(50, 50)local p2 = vec2(150, 150)local blue = rgbm(0, 0, 1, 1)
local radius = 10-- round only top-left and top-right cornerslocal corners = ui.CornerFlags.Toplocal width = 3.0
ui.drawRect(p1, p2, blue, radius, corners, width)