Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Rectangle

Represents a Rectangle

Hierarchy

  • Rectangle

Implements

Index

Constructors

constructor

  • new Rectangle(_x?: number, _y?: number, _width?: number, _height?: number, _angle?: number): Rectangle
  • Creates a new Rectangle

    Parameters

    • Default value _x: number = 0

      Abscissa of center

    • Default value _y: number = 0

      Ordinate of center

    • Default value _width: number = 0

      width of Rectangle

    • Default value _height: number = 0

      height of Rectangle

    • Default value _angle: number = 0

      rotation

    Returns Rectangle

Properties

Private _angle

_angle: number

rotation

Private _height

_height: number

height of Rectangle

Private _width

_width: number

width of Rectangle

Private _x

_x: number

Abscissa of center

Private _y

_y: number

Ordinate of center

Protected halfHeight

halfHeight: number

Protected halfWidth

halfWidth: number

Accessors

angle

  • get angle(): number

height

  • get height(): number

width

  • get width(): number

x

  • get x(): number

y

  • get y(): number

Methods

clone

collides

  • collides(shape: Shape<any>): boolean
  • Checks if Rectangle collides another shape

    Parameters

    • shape: Shape<any>

      Shape to check

    Returns boolean

    true only if provided shape collides current Rectangle

contains

  • contains(p: Point): boolean
  • contains(coordX: number, coordY: number): boolean
  • Checks if a point is within the bounds (inclusive) of a Rectangle

    Parameters

    • p: Point

      Point to check

    Returns boolean

    true only if Point is inside current Rectangle

  • Parameters

    • coordX: number
    • coordY: number

    Returns boolean

getVertices

  • getVertices(): Array<Point>
  • lists vertices of the rectangle

    Returns Array<Point>

    Vertices of the Rectangle, two adjacents vertices in the array form an edge of the Rectangle

move

moveTo

reset

  • reset(newX: number, newY: number, newWidth: number, newHeight: number, newAngle?: number): Rectangle
  • Resets Rectangle dimensions

    Parameters

    • newX: number

      New abscissa

    • newY: number

      New ordinate

    • newWidth: number

      New width

    • newHeight: number

      New height

    • Default value newAngle: number = 0

      New rotation

    Returns Rectangle

    Current Rectangle

resize

  • resize(newWidth: number, newHeight: number): Rectangle
  • Changes size of Rectangle

    Parameters

    • newWidth: number

      New width

    • newHeight: number

      New height

    Returns Rectangle

    Current Rectangle

rotate

rotateRad

scale

Static asRect

  • asRect(x: number, y: number, width: number, height: any): Rectangle
  • Helper method to create a rectangle from its upper-left corner

    Parameters

    • x: number

      Abscissa of upper-left corner

    • y: number

      Ordinate of upper-left corner

    • width: number

      width of Rectangle

    • height: any

      height of Rectangle

    Returns Rectangle

    Corresponding Rectangle

Generated using TypeDoc