A 2D rectangle.

Rectangles are used with 2D primitive managers.

A rectangle is aligned on the pixel boundaries. Its origin is the lowest value in x and y.


Maths

Constructors

  • Creates an rectangle with an origin point [pX,pY] and a size of [pWidth * pHeight].

    The other end point has the coordinate [pX+pWidth,pY+pHeight]. For the screen, [pX,pY] is the top left position of the 2D rectangle.

    Parameters

    • Optional pX: number
      in
      x coordinate of the origin of the rectangle.
    • Optional pY: number
      in
      y coordinate of the origin of the rectangle.
    • Optional pWidth: number
      in
      Width of the rectangle.
    • Optional pHeight: number
      in
      Height of the rectangle.

    Returns Rectangle

    The newly constructed Rectangle.

Properties

height: number

Height of the rect (negative value is invalid).

width: number

Width of the rect (negative value is invalid).

x: number

x coordinate of the origin of the rectangle (minimum of x coordinate of the rectangle).

This corresponds to the minimum abscissa of the rectangle. Since minimum screen abscissa is the left of the screen, x=0 for a rectangle on the left of the screen.

y: number

y coordinate of the origin of the rectangle (minimum of y coordinate of the rectangle).

This corresponds to the minimum ordinate of the rectangle. Since minimum screen ordinate is the top of the screen, y=0 for a rectangle on top of the screen.

Methods

  • Clears the rectangle, i.e. sets the width and height to negative values.

    Returns void

  • Copies this to pOut rectangle.

    If pOut is not supplied, a new Rectangle is allocated.

    Parameters

    • Optional pOut: Rectangle
      out
      The Rectangle to copy to.

    Returns Rectangle

    The copied Rectangle.

  • Tells if the two rectangles are strictly identical.

    Parameters

    • pOtherRectangle: Rectangle
      in
      The other rectangle to compare to.

    Returns boolean

    true if the two rectangles are strictly identical.

  • Sets the content of the Rectangle from a former call to toJSON.

    Parameters

    • pRectangleData: string | Object
      in
      Internal Rectangle data to set.

    Returns boolean

    true if the data is set.

  • Tells if the rectangle is empty.

    An empty rectangle is either a invalid rectangle or a valid rectangle with zero height or width.

    Returns boolean

    true if the rectangle is empty.

  • Tells if the width and the height of the rectangle are positive or equal to zero.

    Returns boolean

    true if the rectangle is a valid mathematical object.

  • Serializes the given Rectangle to JSON.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The JSON representation of the object.