#

API Documentation for: 0.8.1
Show: Inherited Protected Private Deprecated

# Rectangle Class

Defined in: `Rectangle:41`
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]`

)

Defined in `Rectangle:41`

#### 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.

- Index
- Methods
- Properties

## Item Index

### Methods

- clone
- contains
- copy
- extend
- initialize deprecated
- intersection
- intersects
- isEmpty
- pad
- setValues
- toString
- union

### Properties

- height
- width
- x
- y

## Methods

### `clone`

() Rectangle

Defined in `clone:230`

Returns a clone of the Rectangle instance.

#### Returns:

Rectangle:

a clone of the Rectangle instance.

### `contains`

(

- `x`
- `y`
- `[width=0]`
- `[height=0]`

)
Boolean

Defined in `contains:170`

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`

)
Rectangle chainable

Defined in `copy:159`

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]`

)
Rectangle chainable

Defined in `extend:121`

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

Defined in `initialize:87`

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`

)
Rectangle

Defined in `intersection:195`

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`

)
Boolean

Defined in `intersects:211`

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`

() Boolean

Defined in `isEmpty:221`

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`

)
Rectangle chainable

Defined in `pad:141`

Adds the specified padding to the rectangle's bounds.

#### Parameters:

- `top` Number
- `left` Number
- `right` Number
- `bottom` Number

#### Returns:

Rectangle:

This instance. Useful for chaining method calls.

### `setValues`

(

- `[x=0]`
- `[y=0]`
- `[width=0]`
- `[height=0]`

)
Rectangle chainable

Defined in `setValues:102`

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`

() String

Defined in `toString:239`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

### `union`

(

- `rect`

)
Rectangle

Defined in `union:185`

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

### `height`

Number

Defined in `height:79`

Height.

### `width`

Number

Defined in `width:73`

Width.

### `x`

Number

Defined in `x:61`

X position.

### `y`

Number

Defined in `y:67`

Y position.