Luduvo Contents
Theme
On this page

Rect

2D bounds such as UI margins and screen extents

Constructors

1 member Access: shared

new(minX: number?, minY: number?, maxX: number?, maxY: number?) -> Rect

make a rectangle of two corners

Parameters
NameTypeDescription
minXnumber?Left edge coordinate.
minYnumber?Top edge coordinate.
maxXnumber?Right edge coordinate.
maxYnumber?Bottom edge coordinate.
returnsRect—

Constructing 2D Bounding Rectangles

Lifecycle: Shared

A rect stores two corners and derives its width and height from them.

Luau
local minPoint = Vector2.new(10, 20)local maxPoint = Vector2.new(210, 120)local bounds = Rect.new(minPoint, maxPoint)local width = bounds.Widthlocal height = bounds.Heightprint(string.format("Rectangle dimensions: %d x %d", width, height))