Skip to main content

Class: Rects

Defined in: math/rect.ts:16

Static operations on Rect, mirroring the Vector2/Vec2 convention.

Constructors​

Constructor​

new Rects(): Rects

Returns​

Rects

Accessors​

zero​

Get Signature​

get static zero(): Rect

Defined in: math/rect.ts:21

A zero-size rect at the origin. A fresh instance is created on every access, so it's always safe to mutate.

Returns​

Rect

Methods​

clone()​

static clone(rect): Rect

Defined in: math/rect.ts:72

Creates a deep copy of a rect.

Parameters​

rect​

Rect

The rect to copy.

Returns​

Rect

A new Rect with the same corner values.


contains()​

static contains(rect, point): boolean

Defined in: math/rect.ts:43

Checks if a point is inside a rect, inclusive of its edges.

Parameters​

rect​

Rect

The rect to check.

point​

Vector2

The point to check.

Returns​

boolean

True if the point is inside the rect, false otherwise.


intersects()​

static intersects(a, b): boolean

Defined in: math/rect.ts:58

Checks if two rects overlap, inclusive of touching edges/corners.

Parameters​

a​

Rect

The first rect.

b​

Rect

The second rect.

Returns​

boolean

True if the rects overlap, false otherwise.


size()​

static size(rect): Vector2

Defined in: math/rect.ts:30

Calculates a rect's size.

Parameters​

rect​

Rect

The rect.

Returns​

Vector2

A new Vector2 holding max - min.