An axis aligned rectangle. Used by anchors and offsets in ScreenTransform to represent screen boundaries. Rect can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.

// @input Component.ScreenTransform screenTransform

// Move the ScreenTransform's anchor center
script.screenTransform.anchors.setCenter(new vec2(-0.25, 0.5));

// Change the ScreenTransform's anchor size
script.screenTransform.anchors.setSize(new vec2(0.25, 0.25));
interface Rect {
    bottom: number;
    left: number;
    right: number;
    top: number;
    getCenter(): vec2;
    getSize(): vec2;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    setCenter(value: vec2): void;
    setSize(value: vec2): void;
    toString(): string;
}

Hierarchy (view full)

Properties

bottom: number

The y position of the rectangle's bottom side.

left: number

The x position of the rectangle's left side.

right: number

The x position of the rectangle's right side.

top: number

The y position of the rectangle's top side.

Methods

  • Returns the rectangle's center position as (x, y).

    Returns vec2

  • Returns the size of the rectangle as (width, height).

    Returns vec2

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Sets the rectangle's center position while maintaining its size.

    Parameters

    Returns void

  • Sets the rectangle's size while maintaining its center position.

    Parameters

    Returns void

  • Returns a string representation of the Rect.

    Returns string