API Documentation for: 0.8.2
Show:

Rectangle Class

Module: EaselJS

Represents a rectangle as defined by the points (x, y) and (x+width, y+height).

Example

`` var rect = new createjs.Rectangle(0, 0, 100, 100);``

Constructor

`Rectangle`

(
• `[x=0]`
• `[y=0]`
• `[width=0]`
• `[height=0]`
)

Parameters:

• `[x=0]` Number optional

X position.

• `[y=0]` Number optional

Y position.

• `[width=0]` Number optional

The width of the Rectangle.

• `[height=0]` Number optional

The height of the Rectangle.

Methods

`clone`

()

Returns a clone of the Rectangle instance.

Returns:

Rectangle:

a clone of the Rectangle instance.

`contains`

(
• `x`
• `y`
• `[width=0]`
• `[height=0]`
)

Returns true if this rectangle fully encloses the described point or rectangle.

Parameters:

• `x` Number

X position of the point or rectangle.

• `y` Number

Y position of the point or rectangle.

• `[width=0]` Number optional

The width of the rectangle.

• `[height=0]` Number optional

The height of the rectangle.

Returns:

Boolean:

True if the described point or rectangle is contained within this rectangle.

`copy`

(
• `rectangle`
)
chainable

Copies all properties from the specified rectangle to this rectangle.

Parameters:

• `rectangle` Rectangle

The rectangle to copy properties from.

Returns:

Rectangle:

This rectangle. Useful for chaining method calls.

`extend`

(
• `x`
• `y`
• `[width=0]`
• `[height=0]`
)
chainable

Extends the rectangle's bounds to include the described point or rectangle.

Parameters:

• `x` Number

X position of the point or rectangle.

• `y` Number

Y position of the point or rectangle.

• `[width=0]` Number optional

The width of the rectangle.

• `[height=0]` Number optional

The height of the rectangle.

Returns:

Rectangle:

This instance. Useful for chaining method calls.

`initialize`

() deprecated protected

REMOVED. Removed in favor of using `MySuperClass_constructor`. See extend and promote for details.

There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.

`intersection`

(
• `rect`
)

Returns a new rectangle which describes the intersection (overlap) of this rectangle and the specified rectangle, or null if they do not intersect.

Parameters:

• `rect` Rectangle

The rectangle to calculate an intersection with.

Returns:

Rectangle:

A new rectangle describing the intersection or null.

`intersects`

(
• `rect`
)

Returns true if the specified rectangle intersects (has any overlap) with this rectangle.

Parameters:

• `rect` Rectangle

The rectangle to compare.

Returns:

Boolean:

True if the rectangles intersect.

`isEmpty`

()

Returns true if the width or height are equal or less than 0.

Returns:

Boolean:

True if the rectangle is empty.

`pad`

(
• `top`
• `left`
• `right`
• `bottom`
)
chainable

Returns:

Rectangle:

This instance. Useful for chaining method calls.

`setValues`

(
• `[x=0]`
• `[y=0]`
• `[width=0]`
• `[height=0]`
)
chainable

Sets the specified values on this instance.

Parameters:

• `[x=0]` Number optional

X position.

• `[y=0]` Number optional

Y position.

• `[width=0]` Number optional

The width of the Rectangle.

• `[height=0]` Number optional

The height of the Rectangle.

Returns:

Rectangle:

This instance. Useful for chaining method calls.

`toString`

()

Returns a string representation of this object.

Returns:

String:

a string representation of the instance.

`union`

(
• `rect`
)

Returns a new rectangle which contains this rectangle and the specified rectangle.

Parameters:

• `rect` Rectangle

The rectangle to calculate a union with.

Returns:

Rectangle:

A new rectangle describing the union.

Properties

Number

Height.

Number

Width.

`x`

Number

Defined in `x:61`

X position.

`y`

Number

Defined in `y:67`

Y position.