Rect
Rectangle in 2D space.
Constructor Summary
Public Constructor | ||
public |
constructor(x: number, y: number, w: number, h: number) Initializes a rectangle. |
Member Summary
Public Members | ||
public |
Height of rectangle. |
|
public |
Width of rectangle. |
|
public |
Left of rectangle. |
|
public |
Top of rectangle. |
Method Summary
Public Methods | ||
public |
Returns the area under the rectangle. |
|
public |
Calculates the center of the rectangle. |
|
public |
Returns an identical instance. |
|
public |
Checks whether a point is contained in the rectangle. |
|
public |
Sets the dimensions of the rectangle. |
|
public |
dimInRange(min: number, max: number): boolean Checks that the dimensions of the rectangle are in the supplied range. |
|
public |
Floors all the properties of the rectangle. |
|
public |
Checks whether two rectangles intersect. |
|
public |
Sorts the rectangles along the supplied axis. |
|
public |
Calculates the overlap with other rectangle along one axis. |
|
public |
Sets the position of the rectangle. |
|
public |
Rounds all the properties of the rectangle. |
|
public |
Scales the entire rectangle. |
|
public |
seperationAxis(b: Rect): string[] Finds the axis that seperate the rectangles. |
|
public |
Sets all properties. |
|
public |
Centers the rectangle on given point. |
|
public |
Shrinks the rectangle about the center. |
|
public |
Splits the rectangle into two along one axis. |
|
public |
Scales the dimensions about the center. |
Public Constructors
Public Members
Public Methods
public contains(v: Vec): boolean source
Checks whether a point is contained in the rectangle.
Params:
Name | Type | Attribute | Description |
v | Vec | Point |
public dimInRange(min: number, max: number): boolean source
Checks that the dimensions of the rectangle are in the supplied range.
public intersect(b: Rect): boolean source
Checks whether two rectangles intersect.
Params:
Name | Type | Attribute | Description |
b | Rect | Rectangle to test against. |
public order(other: Rect, axis: string): Rect[] source
Sorts the rectangles along the supplied axis.
public overlap(other: Rect, axis: string): int[] source
Calculates the overlap with other rectangle along one axis.
Return:
int[] (nullable: true) | Two element tuple of |
public scale(f: number): Rect source
Scales the entire rectangle.
Params:
Name | Type | Attribute | Description |
f | number | Factor to scale by |
public seperationAxis(b: Rect): string[] source
Finds the axis that seperate the rectangles.
Params:
Name | Type | Attribute | Description |
b | Rect | Other rectangle |
public setCenter(v: Vec): Rect source
Centers the rectangle on given point.
Params:
Name | Type | Attribute | Description |
v | Vec | Center point |
public shrink(val: number): Rect source
Shrinks the rectangle about the center.
Params:
Name | Type | Attribute | Description |
val | number | Amount to shrink |