@baku89/pave - v0.4.1 / Rect
Namespace: Rect
Functions for manipulating rects represented as Rect.
Properties
bottom
▸ bottom(bbox
): number
Returns the bottom coordinate of the given rect in Y-down coordinates such as SVG.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to get the bottom of |
Returns
number
The bottom coordinate of the rect
Defined in
center
▸ center(bbox
): vec2
Calculates the center of the given rect.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to calculate the center of |
Returns
vec2
The center of the rect
Defined in
left
▸ left(bbox
): number
Returns the left coordinate of the given rect in Y-down coordinates such as SVG.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to get the left of |
Returns
number
The left coordinate of the rect
Defined in
right
▸ right(bbox
): number
Returns the right coordinate of the given rect in Y-down coordinates such as SVG.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to get the right of |
Returns
number
The right coordinate of the rect
Defined in
size
▸ size(bbox
): vec2
Calculates the size of the given rect.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to calculate the size of |
Returns
vec2
The size of the rect
Defined in
top
▸ top(bbox
): number
Returns the top coordinate of the given rect in Y-down coordinates such as SVG.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to get the top of |
Returns
number
The top coordinate of the rect
Defined in
Generators
bySize
▸ bySize(min
, size
): Rect
Creates a rect from the minimum point and the size.
Parameters
Name | Type | Description |
---|---|---|
min | vec2 | Top-left point of the rect, in Y-down coordinates such as SVG |
size | vec2 | The size of the rect. |
Returns
The created rect
Defined in
fromCenter
▸ fromCenter(center
, size
): Rect
Creates a rect from the center and the size.
Parameters
Name | Type | Description |
---|---|---|
center | vec2 | The center of the rect |
size | vec2 | The size of the rect |
Returns
The created rect
Defined in
fromDOMRect
▸ fromDOMRect(domRect
): Rect
Creates a rect from the given DOMRect.
Parameters
Name | Type | Description |
---|---|---|
domRect | DOMRect | The DOMRect to create a rect from |
Returns
The created rect
Defined in
fromPoints
▸ fromPoints(...points
): Rect
Creates a rect that contains all the given points.
Parameters
Name | Type | Description |
---|---|---|
...points | vec2 [] | The points to create a rect from |
Returns
The created rect
Defined in
Other
contains
▸ contains(source
, target
): boolean
Checks if the given rect contains the other rect.
Parameters
Name | Type | Description |
---|---|---|
source | Rect | The source rect |
target | Rect | The target rect to check if it’s contained in the source rect |
Returns
boolean
True if the source rect contains the target rect, false otherwise
Defined in
containsPoint
▸ containsPoint(bbox
, point
): boolean
Checks if the given rect contains the given point.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The source rect |
point | vec2 | The point to check if it’s contained in the source rect |
Returns
boolean
True if the rect contains the point, false otherwise
Defined in
intersect
▸ intersect(...rects
): Rect
Calculates the intersection of the given rects.
Parameters
Name | Type | Description |
---|---|---|
...rects | Rect [] | The rects to intersect |
Returns
The intersected rect
Defined in
intersects
▸ intersects(a
, b
): boolean
Checks if the given rects intersect.
Parameters
Name | Type | Description |
---|---|---|
a | Rect | The first rect |
b | Rect | The second rect |
Returns
boolean
True if the rects intersect, false otherwise
Defined in
scale
▸ scale(bbox
, scale
): Rect
Scales the given rect by the given ratio.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to scale |
scale | number | vec2 | The ratio to scale the rect by |
Returns
The scaled rect
Defined in
translate
▸ translate(bbox
, offset
): Rect
Translates the given rect by the given offset.
Parameters
Name | Type | Description |
---|---|---|
bbox | Rect | The rect to translate |
offset | vec2 | The offset to translate the rect by |
Returns
The translated rect
Defined in
unite
▸ unite(...rects
): Rect
Unites the given rects into a single rect.
Parameters
Name | Type | Description |
---|---|---|
...rects | Rect [] | The rects to unite |
Returns
The united rect