Skip to main content

Class: GeometryUtils

Defined in: utils/GeometryUtils.ts:4

Utility methods for rectangle and dimension geometry

Constructors​

Constructor​

new GeometryUtils(): GeometryUtils

Returns​

GeometryUtils

Methods​

dilate()​

static dilate(rect, amount): Rect

Defined in: utils/GeometryUtils.ts:51

Grows a rectangle by the same amount on every side

Parameters​

rect​

Rect

The rectangle to grow

amount​

number

The amount to move every side outwards by; negative amounts shrink the rectangle

Returns​

Rect

The grown rectangle


dimsEquals()​

static dimsEquals(a, b): boolean

Defined in: utils/GeometryUtils.ts:67

Checks if two dimensions are equal by comparing their width and height properties

Parameters​

a​

Dims

The first dimensions to compare

b​

Dims

The second dimensions to compare

Returns​

boolean

true if the dimensions are equal, false otherwise


intersection()​

static intersection(a, b): Rect | null

Defined in: utils/GeometryUtils.ts:32

Computes the intersection of two rectangles

Parameters​

a​

Rect

The first rectangle

b​

Rect

The second rectangle

Returns​

Rect | null

The rectangle covered by both, or null if they do not overlap (touching edges do not count as overlapping)


rectEquals()​

static rectEquals(a, b): boolean

Defined in: utils/GeometryUtils.ts:78

Checks if two rectangles are equal by comparing their x, y, width, and height properties

Parameters​

a​

Rect

The first rectangle to compare

b​

Rect

The second rectangle to compare

Returns​

boolean

true if the rectangles are equal, false otherwise


union()​

static union(...rects): Rect | null

Defined in: utils/GeometryUtils.ts:11

Computes the union of multiple rectangles and returns the smallest rectangle that contains all of them

Parameters​

rects​

...Rect[]

The rectangles to compute the union of

Returns​

Rect | null

The smallest rectangle that contains all the input rectangles, or null if no rectangles are provided