Rectangle
Static Method Summary
| Static Public Methods | ||
| public static |
fromSquare(x: number, y: number, size: number): * Constructs a new square rectangle |
|
| public static |
Creates a rectangle from top right bottom and left offsets |
|
| public static |
fromTwoPoints(p1: Vector, p2: Vector): * |
|
| public static |
intersects(a: Rectangle, b: Rectangle): * Returns if a intersects b |
|
Constructor Summary
| Public Constructor | ||
| public |
|
|
Method Summary
| Public Methods | ||
| public |
Scales every parameter (w, h, x, y) by the given factor. |
|
| public |
|
|
| public |
Returns the bottom left point |
|
| public |
Copies this instance |
|
| public |
containsCircle(x: number, y: number, radius: number): boolean Returns if the rectangle contains the given circle at (x, y) with the radius (radius) |
|
| public |
containsPoint(x: number, y: number): boolean Returns if hte rectangle contains the given point |
|
| public |
containsRect(rect: Rectangle): boolean Returns if the given rectangle is contained |
|
| public |
Returns if this rectangle contains the other rectangle specified by the parameters |
|
| public |
equalsEpsilon(other: Rectangle, epsilon: number): * Returns if this rectangle is equal to the other while taking an epsilon into account |
|
| public |
expandedInAllDirections(amount: number): Rectangle Expands the rectangle in all directions |
|
| public |
Returns the center of the rect |
|
| public |
getIntersection(rect: Rectangle): Rectangle | null Returns the shared area with another rectangle, or null if there is no intersection |
|
| public |
Returns the union of this rectangle with another |
|
| public |
Returns if this rectangle is empty |
|
| public |
|
|
| public |
Moves the rectangle by the given parameters |
|
| public |
moveByVector(vec: Vector) Moves the rectangle by the given vector |
|
| public |
|
|
| public |
Sets the bottom side of the rect without moving it |
|
| public |
Sets the left side of the rect without scaling it |
|
| public |
Sets the right side of the rect without moving it |
|
| public |
Sets the top side of the rect without scaling it |
|
| public |
toCompareableString(): * Good for caching stuff |
|
| public |
toString(): * Good for printing stuff |
|
| public |
Returns a new rectangle in tile space which includes all tiles which are visible in this rect |
|
| public |
|
|
| public |
Returns the top left point |
|
| public |
trbl(): [number, number, number, number] Returns Top, Right, Bottom, Left |
|
Static Public Methods
public static fromSquare(x: number, y: number, size: number): * source
Constructs a new square rectangle
Return:
| * |
public static fromTRBL(top: number, right: number, bottom: number, left: number): * source
Creates a rectangle from top right bottom and left offsets
Return:
| * |
Public Constructors
public constructor() source
Public Methods
public allScaled(factor: number): * source
Scales every parameter (w, h, x, y) by the given factor. Useful to transform from world to tile space and vice versa
Params:
| Name | Type | Attribute | Description |
| factor | number |
Return:
| * |
public containsCircle(x: number, y: number, radius: number): boolean source
Returns if the rectangle contains the given circle at (x, y) with the radius (radius)
public containsPoint(x: number, y: number): boolean source
Returns if hte rectangle contains the given point
public containsRect(rect: Rectangle): boolean source
Returns if the given rectangle is contained
Params:
| Name | Type | Attribute | Description |
| rect | Rectangle |
public containsRect4Params(x: number, y: number, w: number, h: number): boolean source
Returns if this rectangle contains the other rectangle specified by the parameters
public equalsEpsilon(other: Rectangle, epsilon: number): * source
Returns if this rectangle is equal to the other while taking an epsilon into account
Return:
| * |
public expandedInAllDirections(amount: number): Rectangle source
Expands the rectangle in all directions
Params:
| Name | Type | Attribute | Description |
| amount | number |
public getIntersection(rect: Rectangle): Rectangle | null source
Returns the shared area with another rectangle, or null if there is no intersection
Params:
| Name | Type | Attribute | Description |
| rect | Rectangle |
public getUnion(rect: Rectangle): * source
Returns the union of this rectangle with another
Params:
| Name | Type | Attribute | Description |
| rect | Rectangle |
Return:
| * |
public moveByVector(vec: Vector) source
Moves the rectangle by the given vector
Params:
| Name | Type | Attribute | Description |
| vec | Vector |
public setBottom(bottom: number) source
Sets the bottom side of the rect without moving it
Params:
| Name | Type | Attribute | Description |
| bottom | number |
public setLeft(left: number) source
Sets the left side of the rect without scaling it
Params:
| Name | Type | Attribute | Description |
| left | number |
public setRight(right: number) source
Sets the right side of the rect without moving it
Params:
| Name | Type | Attribute | Description |
| right | number |
public setTop(top: number) source
Sets the top side of the rect without scaling it
Params:
| Name | Type | Attribute | Description |
| top | number |
public toTileCullRectangle(): Rectangle source
Returns a new rectangle in tile space which includes all tiles which are visible in this rect
public trbl(): [number, number, number, number] source
Returns Top, Right, Bottom, Left
Return:
| [number, number, number, number] |
