Rectangle Class
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.
Constructor
Rectangle
-
x
-
y
-
width
-
height
Parameters:
-
x
NumberThe X coord of the upper-left corner of the rectangle
-
y
NumberThe Y coord of the upper-left corner of the rectangle
-
width
NumberThe overall wisth of this rectangle
-
height
NumberThe overall height of this rectangle
Item Index
Methods
contains
-
x
-
y
Checks if the x, and y coords passed to this function are contained within this Rectangle
Parameters:
-
x
NumberThe X coord of the point to test
-
y
NumberThe Y coord of the point to test
Returns:
if the x/y coords are within this Rectangle
copy
-
rectangle
Copies the values from another rectangle to this one
Parameters:
-
rectangle
RectangleThe rectangle to copy vlaues from
Returns:
Returns itself.
equals
-
rectangle
Checks if this rectangle's values are equal to anothers
Parameters:
-
rectangle
RectangleThe rectangle to check against
Returns:
True if they are equal
overlaps
-
rect
Checks if this rectangle overlaps another
Parameters:
-
rect
RectangleThe rectangle to check if this overlaps
Returns:
if the rectangle overlaps
toPolygon
()
Polygon
Returns a polygon from this rectangle's points
Returns:
The new polygon
Properties
_height
Number
private
Default: 0
_width
Number
private
Default: 0
area
Number
The area of the rectangle
bottom
Number
Returns the bottom most Y coord
halfHeight
Number
Default: 0
halfWidth
Number
Default: 0
height
Number
The height of the object
left
Number
Returns the left most X coord
perimeter
Number
The perimeter of the rectangle
right
Number
Returns the right most X coord
top
Number
Returns the top most Y coord
width
Number
The width of the object
Default: 0
x
Number
The top-left X coord of the rectangle
Default: 0
y
Number
The top-left Y coord of the rectangle
Default: 0