Class: Rectangle

Rectangle

the Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height.


new Rectangle(x, y, width, height)

Parameters:
Name Type Description
x number

The X coordinate of the upper-left corner of the rectangle

y number

The Y coordinate of the upper-left corner of the rectangle

width number

The overall width of this rectangle

height number

The overall height of this rectangle

Source:

Members


<static, constant> EMPTY

A constant empty rectangle.

Source:

height :number

Type:
  • number
Default Value:
  • 0
Source:

type :number

The type of the object, mainly used to avoid instanceof checks

Type:
  • number
Source:

width :number

Type:
  • number
Default Value:
  • 0
Source:

x :number

Type:
  • number
Default Value:
  • 0
Source:

y :number

Type:
  • number
Default Value:
  • 0
Source:

Methods


clone()

Creates a clone of this Rectangle

Source:
Returns:

a copy of the rectangle

Type
Rectangle

contains(x, y)

Checks whether the x and y coordinates given are contained within this Rectangle

Parameters:
Name Type Description
x number

The X coordinate of the point to test

y number

The Y coordinate of the point to test

Source:
Returns:

Whether the x/y coordinates are within this Rectangle

Type
boolean