DrawingImmediate. Rectangle Synchronous
Draw a rectangle outline from its upper-left position, width, and height. Rounding controls the corners. Use it for the border of a panel or selection box.
Luau
DrawingImmediate.Rectangle(
position: Vector2,
size: Vector2,
color: Color3,
opacity: number,
rounding: number,
thickness: number
) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
position | Vector2 | Upper-left anchor in screen pixels; centered text uses this as its horizontal center. |
size | Vector2 | Dimensions of the rectangle. |
color | Color3 | Color3 used for the primitive or text. |
opacity | number | Opacity from 0 (invisible) to 1 (opaque). |
rounding | number | Corner rounding of the rectangle. |
thickness | number | Stroke thickness for an unfilled primitive. |
Returns
()This function returns no values.
Usage notes
Immediate drawings last for one paint cycle. Call this function again from a GetPaint listener to keep the drawing visible; there is no object handle to update or remove.
Example
Luau
local color = Color3.fromRGB(240, 150, 190)
local paint = DrawingImmediate.GetPaint()
local connection = paint:Connect(function()
DrawingImmediate.Rectangle(Vector2.new(40, 40), Vector2.new(180, 80), color, 1, 8, 2)
end)
task.wait(3)
connection:Disconnect() -- stop drawing this example