Class Rect2

A 2D axis-aligned bounding box (AABB). Includes extra methods for math and utility.

Hierarchy

  • Rect2

Implements

Constructors

Properties

pos: Vector2

The position of the rectangle. (Top-left corner if x and y of size are both >= 0)

size: Vector2

The size of the rectangle.

Accessors

  • get perimeter(): number
  • Returns the perimeter of the Rect2.

    Returns number

  • get screen(): Rect2
  • Converts the Rect2 from world coordinates to screen coordinates using the currentCamera.

    Returns Rect2

  • get world(): Rect2
  • Converts the Rect2 from screen coordinates to world coordinates using the currentCamera.

    Returns Rect2

Methods

  • Expands the size of the Rect2 by a number equally on all sides. Creates a new Rect2 and does not modify the original Rect2.

    Parameters

    • px: number

    Returns Rect2

  • Expands the size of the Rect2 by a number equally on all sides. Modifies the original Rect2.

    Parameters

    • px: number

    Returns Rect2

  • Scales the Rect2 by a scale factor. Creates a new Rect2 and does not modify the original Rect2.

    Parameters

    • f: number

    Returns Rect2

  • Scales the Rect2 by a scale factor. Modifies the original Rect2.

    Parameters

    • f: number

    Returns Rect2

  • Creates a Rect2 from x, y, width, and height numbers instead of pos and size

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns Rect2

Generated using TypeDoc