#

API Documentation for: NEXT
Show: Inherited Protected Private Deprecated

# Matrix2D Class

Defined in: `Matrix2D:41`
Module: EaselJS

Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.

This matrix can be visualized as:

    [ a  c  tx
      b  d  ty
      0  0  1  ]

Note the locations of b and c.

## Constructor

### `Matrix2D`

(

- `[a=1]`
- `[b=0]`
- `[c=0]`
- `[d=1]`
- `[tx=0]`
- `[ty=0]`

)

Defined in `Matrix2D:41`

#### Parameters:

- `[a=1]` Number optional

  Specifies the a property for the new matrix.

- `[b=0]` Number optional

  Specifies the b property for the new matrix.

- `[c=0]` Number optional

  Specifies the c property for the new matrix.

- `[d=1]` Number optional

  Specifies the d property for the new matrix.

- `[tx=0]` Number optional

  Specifies the tx property for the new matrix.

- `[ty=0]` Number optional

  Specifies the ty property for the new matrix.

- Index
- Methods
- Properties

## Item Index

### Methods

- append
- appendMatrix
- appendTransform
- clone
- copy
- decompose
- equals
- identity
- initialize deprecated
- invert
- isIdentity
- prepend
- prependMatrix
- prependTransform
- rotate
- scale
- setValues
- skew
- toString
- transformPoint
- translate

### Properties

- a
- b
- c
- d
- DEG_TO_RAD static
- identity static
- tx
- ty

## Methods

### `append`

(

- `a`
- `b`
- `c`
- `d`
- `tx`
- `ty`

)
Matrix2D

Defined in `append:164`

Appends the specified matrix properties to this matrix. All parameters are required. This is the equivalent of multiplying `(this matrix) * (specified matrix)`.

#### Parameters:

- `a` Number
- `b` Number
- `c` Number
- `d` Number
- `tx` Number
- `ty` Number

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `appendMatrix`

(

- `matrix`

)
Matrix2D

Defined in `appendMatrix:219`

Appends the specified matrix to this matrix. This is the equivalent of multiplying `(this matrix) * (specified matrix)`.

#### Parameters:

- `matrix` Matrix2D

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `appendTransform`

(

- `x`
- `y`
- `scaleX`
- `scaleY`
- `rotation`
- `skewX`
- `skewY`
- `regX`
- `regY`

)
Matrix2D

Defined in `appendTransform:249`

Generates matrix properties from the specified display object transform properties, and appends them to this matrix. For example, you can use this to generate a matrix representing the transformations of a display object:

    var mtx = new Matrix2D();
    mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);

#### Parameters:

- `x` Number
- `y` Number
- `scaleX` Number
- `scaleY` Number
- `rotation` Number
- `skewX` Number
- `skewY` Number
- `regX` Number

  Optional.

- `regY` Number

  Optional.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `clone`

() Matrix2D

Defined in `clone:521`

Returns a clone of the Matrix2D instance.

#### Returns:

Matrix2D:

a clone of the Matrix2D instance.

### `copy`

(

- `matrix`

)
Matrix2D

Defined in `copy:511`

Copies all properties from the specified matrix to this matrix.

#### Parameters:

- `matrix` Matrix2D

  The matrix to copy properties from.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `decompose`

(

- `target`

)
Object

Defined in `decompose:478`

Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values may not match the transform properties you used to generate the matrix, though they will produce the same visual results.

#### Parameters:

- `target` Object

  The object to apply the transform properties to. If null, then a new object will be returned.

#### Returns:

Object:

The target, or a new generic object with the transform properties applied.

### `equals`

(

- `matrix`

)
Boolean

Defined in `equals:453`

Returns true if this matrix is equal to the specified matrix (all property values are equal).

#### Parameters:

- `matrix` Matrix2D

  The matrix to compare.

#### Returns:

Boolean:

### `identity`

() Matrix2D

Defined in `identity:411`

Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `initialize`

() deprecated protected

Defined in `initialize:104`

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.

### `invert`

() Matrix2D

Defined in `invert:422`

Inverts the matrix, causing it to perform the opposite transformation.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `isIdentity`

() Boolean

Defined in `isIdentity:444`

Returns true if the matrix is an identity matrix.

#### Returns:

Boolean:

### `prepend`

(

- `a`
- `b`
- `c`
- `d`
- `tx`
- `ty`

)
Matrix2D

Defined in `prepend:192`

Prepends the specified matrix properties to this matrix. This is the equivalent of multiplying `(specified matrix) * (this matrix)`. All parameters are required.

#### Parameters:

- `a` Number
- `b` Number
- `c` Number
- `d` Number
- `tx` Number
- `ty` Number

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `prependMatrix`

(

- `matrix`

)
Matrix2D

Defined in `prependMatrix:230`

Prepends the specified matrix to this matrix. This is the equivalent of multiplying `(specified matrix) * (this matrix)`. For example, you could calculate the combined transformation for a child object using:

    var o = myDisplayObject;
    var mtx = o.getMatrix();
    while (o = o.parent) {
        // prepend each parent's transformation in turn:
        o.prependMatrix(o.getMatrix());
    }

#### Parameters:

- `matrix` Matrix2D

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `prependTransform`

(

- `x`
- `y`
- `scaleX`
- `scaleY`
- `rotation`
- `skewX`
- `skewY`
- `regX`
- `regY`

)
Matrix2D

Defined in `prependTransform:295`

Generates matrix properties from the specified display object transform properties, and prepends them to this matrix. For example, you could calculate the combined transformation for a child object using:

    var o = myDisplayObject;
    var mtx = new createjs.Matrix2D();
    do  {
        // prepend each parent's transformation in turn:
        mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
    } while (o = o.parent);

    Note that the above example would not account for transformMatrix
    values. See prependMatrix for an example that does.

#### Parameters:

- `x` Number
- `y` Number
- `scaleX` Number
- `scaleY` Number
- `rotation` Number
- `skewX` Number
- `skewY` Number
- `regX` Number

  Optional.

- `regY` Number

  Optional.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `rotate`

(

- `angle`

)
Matrix2D

Defined in `rotate:346`

Applies a clockwise rotation transformation to the matrix.

#### Parameters:

- `angle` Number

  The angle to rotate by, in degrees. To use a value in radians, multiply it by `180/Math.PI`.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `scale`

(

- `x`
- `y`

)
Matrix2D

Defined in `scale:381`

Applies a scale transformation to the matrix.

#### Parameters:

- `x` Number

  The amount to scale horizontally. E.G. a value of 2 will double the size in the X direction, and 0.5 will halve it.

- `y` Number

  The amount to scale vertically.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `setValues`

(

- `[a=1]`
- `[b=0]`
- `[c=0]`
- `[d=1]`
- `[tx=0]`
- `[ty=0]`

)
Matrix2D

Defined in `setValues:142`

Sets the specified values on this instance.

#### Parameters:

- `[a=1]` Number optional

  Specifies the a property for the new matrix.

- `[b=0]` Number optional

  Specifies the b property for the new matrix.

- `[c=0]` Number optional

  Specifies the c property for the new matrix.

- `[d=1]` Number optional

  Specifies the d property for the new matrix.

- `[tx=0]` Number optional

  Specifies the tx property for the new matrix.

- `[ty=0]` Number optional

  Specifies the ty property for the new matrix.

#### Returns:

Matrix2D:

This instance. Useful for chaining method calls.

### `skew`

(

- `skewX`
- `skewY`

)
Matrix2D

Defined in `skew:367`

Applies a skew transformation to the matrix.

#### Parameters:

- `skewX` Number

  The amount to skew horizontally in degrees. To use a value in radians, multiply it by `180/Math.PI`.

- `skewY` Number

  The amount to skew vertically in degrees.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `toString`

() String

Defined in `toString:530`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

### `transformPoint`

(

- `x`
- `y`
- `[pt]`

)
Point

Defined in `transformPoint:463`

Transforms a point according to this matrix.

#### Parameters:

- `x` Number

  The x component of the point to transform.

- `y` Number

  The y component of the point to transform.

- `[pt]` Point | Object optional

  An object to copy the result into. If omitted a generic object with x/y properties will be returned.

#### Returns:

Point:

This matrix. Useful for chaining method calls.

### `translate`

(

- `x`
- `y`

)
Matrix2D

Defined in `translate:398`

Translates the matrix on the x and y axes.

#### Parameters:

- `x` Number
- `y` Number

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

## Properties

### `a`

Number

Defined in `a:66`

Position (0, 0) in a 3x3 affine transformation matrix.

### `b`

Number

Defined in `b:72`

Position (0, 1) in a 3x3 affine transformation matrix.

### `c`

Number

Defined in `c:78`

Position (1, 0) in a 3x3 affine transformation matrix.

### `d`

Number

Defined in `d:84`

Position (1, 1) in a 3x3 affine transformation matrix.

### `DEG_TO_RAD`

Number final static

Defined in `DEG_TO_RAD:119`

Multiplier for converting degrees to radians. Used internally by Matrix2D.

### `identity`

Matrix2D static

Defined in `identity:131`

An identity matrix, representing a null transformation.

### `tx`

Number

Defined in `tx:90`

Position (2, 0) in a 3x3 affine transformation matrix.

### `ty`

Number

Defined in `ty:96`

Position (2, 1) in a 3x3 affine transformation matrix.