API Documentation for: 1.0.0
Show:

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.

Methods

clone

() Rectangle

Defined in clone:216

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:156

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:145

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:107

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.

intersection

(
  • rect
)
Rectangle

Defined in intersection:181

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:197

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

Parameters:

Returns:

Boolean:

True if the rectangles intersect.

isEmpty

() Boolean

Defined in isEmpty:207

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

Returns:

Boolean:

True if the rectangle is empty.

pad

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

Defined in pad:127

Adds the specified padding to the rectangle's bounds.

Parameters:

Returns:

Rectangle:

This instance. Useful for chaining method calls.

setValues

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

Defined in setValues:88

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:225

Returns a string representation of this object.

Returns:

String:

a string representation of the instance.

union

(
  • rect
)
Rectangle

Defined in union:171

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.