Rect
Rect
Overview needed
Constructor
public Rect
Properties
private yIsUp: number
Description needed
public left: number
Description needed
public right: number
Description needed
public top: number
Description needed
public bottom: number
Description needed
Methods
private updateX
updateX(x, w) => void
Description needed
Parameters
x: number
– Description neededw: number
– Description needed
private updateY
updateY(y, h) => void
Description needed
Parameters
y: number
– Description neededh: number
– Description needed
public intersects
intersects(rect) => false | true
Description needed
Parameters
-
rect: Rect
– Description needed
Returns
-
false | true
– Description needed
public contains
contains(pt) => false | true
Description needed
Parameters
-
pt: Vector
– Description needed
Returns
-
false | true
– Description needed
public subMargin
subMargin(margin) => Rect
Description needed
Parameters
-
margin: Margin
– Description needed
Returns
-
Rect
– Description needed
public clamp
clamp(bounds) => void
Clamps this rectangle such that it's within the given bounds. (Note that this preserves the size of the rectangle, unless it is larger then the bounds).
Parameters
-
bounds: Rect
– The bounds to clamp this rectangle into.
public sub
sub(rect) => Rect[]
Performs a rectangle subtraction (essentially a XOR), see https://stackoverflow.com/questions/3765283/how-to-subtract-a-rectangle-from-another. This method works slightly differently by instead of calculating the minimum rectangles for the subtraction, calculates all possible 8 rectangles from each side and corner.
Parameters
-
rect: Rect
– Rectangle to subtract from this rectangle.
Returns
-
Rect[]
– The remaining rectangles after the subtraction.
public shift
shift(dir, amt, constraints) => Rect
Shifts the sides of this rectangle given by amt: If dir.x < 0, shifts amt.x left. If dir.x > 0, shifts amt.x right. If dir.y < 0, shifts amt.y down. If dir.y > 0, shifts amt.y up.
Parameters
dir: Vector
– The direction to shift this rectangle.amt: Vector
– The amount to shift this rectangle.constraints: Rect
– The constraints for the shift.
Returns
-
Rect
– A new rectangle which is a shifted version of this one.
Static Methods
public From
From(bounds, yIsUp) => Rect
Utility method to create a rectangle from any combination of valid rectangle attributes, i.e. allows specification of size + center, or bottom left + top right, or any other valid combination.
Parameters
bounds: Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record | Record & Record & Record & Record
– Attributes of rectangle.yIsUp: false | true
– Whether this rectangle has +y or -y.
Returns
-
Rect
– A Rect from the given bounds/attributes and yIsUp direction.