Skip to main content

Rect

Rect

Overview needed


Constructor

public Rect

new Rect(center, size, yIsUp)

*Description needed*

Parameters

  •  center: VectorDescription needed

  •  size: VectorDescription needed

  •  yIsUp: false | trueDescription needed


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: numberDescription needed

  •  w: numberDescription needed

private updateY

updateY(y, h) => void

Description needed

Parameters

  •  y: numberDescription needed

  •  h: numberDescription needed

public intersects

intersects(rect) => false | true

Description needed

Parameters

  •  rect: RectDescription needed

Returns

  •   false | trueDescription needed

public contains

contains(pt) => false | true

Description needed

Parameters

  •  pt: VectorDescription needed

Returns

  •   false | trueDescription needed

public subMargin

subMargin(margin) => Rect

Description needed

Parameters

  •  margin: MarginDescription needed

Returns

  •   RectDescription 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.

Functions

Margin

Margin(left, right, bottom, top) => Margin

Description needed

Parameters

  •  left: numberDescription needed

  •  right: numberDescription needed

  •  bottom: numberDescription needed

  •  top: numberDescription needed

Returns

  •   MarginDescription needed

Margin(h, v) => Margin

Description needed

Parameters

  •  h: numberDescription needed

  •  v: numberDescription needed

Returns

  •   MarginDescription needed