Skip to content

drawRectFilled

Draws a solid, filled rectangle between two defined points on the screen or canvas.

ui.drawRectFilled(p1, p2, color, rounding, roundingFlags)

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).

ParameterTypeRequiredDefaultDescription
p1vec2Yes-Screen coordinates for the first corner.
p2vec2Yes-Screen coordinates for the opposite corner.
colorrgbmYes-The fill color and opacity.
roundingnumberNo0.0The radius of the corners in pixels.
roundingFlagsui.CornerFlagsNoAllBitmask determining which corners are rounded.
  • None

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% opacity
ui.drawRectFilled(p1, p2, black)