Class: GeometryUtils
Defined in: utils/GeometryUtils.ts:4
Utility methods for rectangle and dimension geometry
Constructors
Constructor
new GeometryUtils():
GeometryUtils
Returns
GeometryUtils
Methods
dilate()
staticdilate(rect,amount):Rect
Defined in: utils/GeometryUtils.ts:51
Grows a rectangle by the same amount on every side
Parameters
rect
The rectangle to grow
amount
number
The amount to move every side outwards by; negative amounts shrink the rectangle
Returns
The grown rectangle
dimsEquals()
staticdimsEquals(a,b):boolean
Defined in: utils/GeometryUtils.ts:67
Checks if two dimensions are equal by comparing their width and height properties
Parameters
a
The first dimensions to compare
b
The second dimensions to compare
Returns
boolean
true if the dimensions are equal, false otherwise
intersection()
staticintersection(a,b):Rect|null
Defined in: utils/GeometryUtils.ts:32
Computes the intersection of two rectangles
Parameters
a
The first rectangle
b
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()
staticrectEquals(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
The first rectangle to compare
b
The second rectangle to compare
Returns
boolean
true if the rectangles are equal, false otherwise
union()
staticunion(...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