Represents an axis-aligned bounding rectangle (AABR) defined by position, width and height. The position represents the bottom-left corner of the rectangle.
Provides methods and properties for manipulating and querying the rectangle's geometry.

const rect = new Rectangle(0, 0, 100, 100);
rect.width // 100
rect.height // 100

rect.x // 0
rect.y // 0

rect.x1 // 100
rect.y1 // 100

rect.center // { x: 50, y: 50 }

rect.intersects(new Rectangle(50, 50, 100, 100)) // true

rect.contains(new Vector2(50, 50)) // true

rect.contains(new Rectangle(100, 100, 100, 100)) // false

rect.toString() // "(0, 0, 100, 100)"

Constructors

Properties

height: number = 0
width: number = 0

Accessors

Methods

  • Check if the target rectangle is contained

    Parameters

    Returns boolean

    TRUE or FALSE

  • Check if the target vector is contained

    Parameters

    Returns boolean

    TRUE or FALSE

  • Compare if two rectangles are equals

    Parameters

    • rectangle: Rectangle

      The rectangle to compare

    Returns boolean

    TRUE if the rectangles are equals, FALSE if not

  • Check if the target rectangle is overlapping

    Parameters

    Returns boolean

    TRUE or FALSE

  • Set the rectangle

    Parameters

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

    Returns void