RSX Code Reference
    Preparing search index...

    Class Rect2

    The Rect2 implements a 2D rectangle with an origin in top left and a width and height. The class follows the 'copy-on-write' pattern, which means that every operation such as Rect2#inset or Rect2#outset returns a copy of the rect with updates values. It also implies that the values of the rect cannot be directly modified.

    The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

    Index
    • Parameters

      • Optionalx: number
      • Optionaly: number
      • Optionalwidth: number
      • Optionalheight: number

      Returns Rect2

    _height: number
    _width: number
    _x: number
    _y: number
    • get bottom(): number

      Gets the Y position of the bottom edge.

      Returns number

    • get height(): number

      Returns number

    • set height(value: number): void

      Parameters

      • value: number

      Returns void

    • get left(): number

      Gets the X position of the left edge.

      Returns number

    • get right(): number

      Gets the X position of the right edge.

      Returns number

    • get top(): number

      Gets the Y position of the top edge.

      Returns number

    • get width(): number

      Returns number

    • set width(value: number): void

      Parameters

      • value: number

      Returns void

    • get x(): number

      Returns number

    • set x(value: number): void

      Parameters

      • value: number

      Returns void

    • get y(): number

      Returns number

    • set y(value: number): void

      Parameters

      • value: number

      Returns void

    • Copies all properties defined by the prototype of Rect2 from other to this instance.

      Parameters

      Returns Rect2

    • Clips the point to the rectangle.

      Parameters

      • point: Vector2

        The point to clip.

      Returns void

    • Clones this instance and returns a new Rect2 with identical values.

      Returns Rect2

    • Clips current rectangle so that it does not overlap the provided rectangle. After clipping no area of this rectangle will intersect the clip area.

      Parameters

      Returns Rect2

    • Insets this rectangle by the given amount.

      Parameters

      • inset: number

        The amount to inset the rectangle by.

      Returns Rect2

      This rectangle modified by the given inset.

    • Insets this rectangle by the given amount.

      Parameters

      • outset: number

      Returns Rect2

      This rectangle modified by the given inset.

    • Rounds the vector to the nearest multiple.

      Parameters

      • multiple: number

        Multiple to round to.

      Returns Rect2

      This instance.

      This is a helpful utility to quickly snap an rectangle to a specic grid size.

    • Returns a copy of this rectangle extended by the provided rectangle, so that the given rectangle is completely contained within this.

      Parameters

      Returns Rect2

    • Computes the absolute area of the rectangle.

      Returns number

    • Computes the signed area of the rectangle.

      Returns number

    • Insets a rectangle by the given amount.

      Parameters

      • inset: number

        The amount to inset the rectangle by.

      Returns Rect2

      Returns a new rectangle with the insets applied.

    • Returns whether the provided rect, given a error margin, has the same rect components values as this one.

      Parameters

      • rhs: Immutable<Rect2>

        The other rect to compare with.

      • Optionalepsilon: number

        Optional. Error margin within which the numbers should be considered equal.

      Returns boolean

      True if equal, false otherwise.

    • Determines if both rectangles are element-wise equal.

      Parameters

      Returns boolean

    • Outsets a rectangle by the given amount.

      Parameters

      • outset: number

        The amount to outset the rectangle by.

      Returns Rect2

      Returns a new rectangle with the outsets applied.

    • Returns true if the rectangle overlaps the provided rectangle. Also returns true if the rectangles are contained within each other completely (no intersecting edges).

      Parameters

      Returns boolean

    • Returns a copy of the rectangle rounded to the nearest multiple.

      Parameters

      • multiple: number

        Multiple to round to.

      Returns Rect2

      This instance.

      This is a helpful utility to quickly snap an rectangle to a specic grid size.

    • Assigns the values to the rectangle.

      Parameters

      • Optionalx: number
      • Optionaly: number
      • Optionalwidth: number
      • Optionalheight: number

      Returns void

    • Returns a new Size2 that represents the size of the Rect.

      Returns Size2

    • Returns a string representation of an object.

      Returns string

    • Compares two rectangles with an error margin.

      Parameters

      • lhs: Immutable<Rect2>

        First rect to compare.

      • rhs: Immutable<Rect2>

        Second rect to compare.

      • Optionalepsilon: number

        Optional. Error margin within which the numbers should be considered equal.

      Returns boolean

      True if equal, false otherwise.