#

API Documentation for: NEXT
Show: Inherited Protected Private Deprecated

# Matrix2D Class

Defined in: `Matrix2D:39`
Module: EaselJS

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

## Constructor

### `Matrix2D`

(

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

)

Defined in `Matrix2D:39`

#### 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
- appendProperties
- appendTransform
- clone
- copy
- decompose
- identity
- initialize
- invert
- isIdentity
- prepend
- prependMatrix
- prependProperties
- prependTransform
- reinitialize
- rotate
- scale
- skew
- toString
- transformPoint
- translate

### Properties

- a
- alpha
- b
- c
- compositeOperation
- d
- DEG_TO_RAD static
- identity static
- shadow
- tx
- ty
- visible

## Methods

### `append`

(

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

)
Matrix2D

Defined in `append:203`

Appends the specified matrix properties with 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.

### `appendMatrix`

(

- `matrix`

)
Matrix2D

Defined in `appendMatrix:241`

Appends the specified matrix with this matrix.

#### Parameters:

- `matrix` Matrix2D

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `appendProperties`

(

- `alpha`
- `shadow`
- `compositeOperation`
- `visible`

)
Matrix2D

Defined in `appendProperties:532`

Appends the specified visual properties to the current matrix.

#### Parameters:

- `alpha` Number

  desired alpha value

- `shadow` Shadow

  desired shadow value

- `compositeOperation` String

  desired composite operation value

- `visible` Boolean

  desired visible value

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `appendTransform`

(

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

)
Matrix2D

Defined in `appendTransform:295`

Generates matrix properties from the specified display object transform properties, and appends them with this matrix. For example, you can use this to generate a matrix from 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:566`

Returns a clone of the Matrix2D instance.

#### Returns:

Matrix2D:

a clone of the Matrix2D instance.

### `copy`

(

- `matrix`

)
Matrix2D

Defined in `copy:522`

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`

)
Matrix2D

Defined in `decompose:465`

Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that this 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:

Matrix2D:

This matrix. Useful for chaining method calls.

### `identity`

() Matrix2D

Defined in `identity:406`

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`

(

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

)
Matrix2D

Defined in `initialize:155`

Initialization method. Can also be used to reinitialize the 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.

### `invert`

() Matrix2D

Defined in `invert:419`

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

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `isIdentity`

() Boolean

Defined in `isIdentity:441`

Returns true if the matrix is an identity matrix.

#### Returns:

Boolean:

### `prepend`

(

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

)
Matrix2D

Defined in `prepend:177`

Concatenates the specified matrix properties with 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:229`

Prepends the specified matrix with this matrix.

#### Parameters:

- `matrix` Matrix2D

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `prependProperties`

(

- `alpha`
- `shadow`
- `compositeOperation`
- `visible`

)
Matrix2D

Defined in `prependProperties:549`

Prepends the specified visual properties to the current matrix.

#### Parameters:

- `alpha` Number

  desired alpha value

- `shadow` Shadow

  desired shadow value

- `compositeOperation` String

  desired composite operation value

- `visible` Boolean

  desired visible value

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `prependTransform`

(

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

)
Matrix2D

Defined in `prependTransform:253`

Generates matrix properties from the specified display object transform properties, and prepends them with this matrix. For example, you can use this to generate a matrix from a display object: var mtx = new Matrix2D(); mtx.prependTransform(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.

### `reinitialize`

(

- `[a=1]`
- `[b=0]`
- `[c=0]`
- `[d=1]`
- `[tx=0]`
- `[ty=0]`
- `[alpha=1]`
- `[shadow=null]`
- `[compositeOperation=null]`
- `[visible=true]`

)
Matrix2D

Defined in `reinitialize:498`

Reinitializes all matrix properties to those specified.

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

- `[alpha=1]` Number optional

  desired alpha value

- `[shadow=null]` Shadow optional

  desired shadow value

- `[compositeOperation=null]` String optional

  desired composite operation value

- `[visible=true]` Boolean optional

  desired visible value

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `rotate`

(

- `angle`

)
Matrix2D

Defined in `rotate:339`

Applies a rotation transformation to the matrix.

#### Parameters:

- `angle` Number

  The angle in radians. To use degrees, multiply by `Math.PI/180`.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `scale`

(

- `x`
- `y`

)
Matrix2D

Defined in `scale:376`

Applies a scale transformation to the matrix.

#### Parameters:

- `x` Number

  The amount to scale horizontally

- `y` Number

  The amount to scale vertically

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `skew`

(

- `skewX`
- `skewY`

)
Matrix2D

Defined in `skew:362`

Applies a skew transformation to the matrix.

#### Parameters:

- `skewX` Number

  The amount to skew horizontally in degrees.

- `skewY` Number

  The amount to skew vertically in degrees.

#### Returns:

Matrix2D:

This matrix. Useful for chaining method calls.

### `toString`

() String

Defined in `toString:575`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

### `transformPoint`

(

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

)
Point

Defined in `transformPoint:450`

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:393`

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:78`

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

### `alpha`

Number

Defined in `alpha:120`

Property representing the alpha that will be applied to a display object. This is not part of matrix operations, but is used for operations like getConcatenatedMatrix to provide concatenated alpha values.

### `b`

Number

Defined in `b:85`

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

### `c`

Number

Defined in `c:92`

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

### `compositeOperation`

String

Defined in `compositeOperation:136`

Property representing the compositeOperation that will be applied to a display object. This is not part of matrix operations, but is used for operations like getConcatenatedMatrix to provide concatenated compositeOperation values. You can find a list of valid composite operations at: https://developer.mozilla.org/en/Canvas_tutorial/Compositing

### `d`

Number

Defined in `d:99`

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

### `DEG_TO_RAD`

Number final static

Defined in `DEG_TO_RAD:66`

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

### `identity`

Matrix2D static

Defined in `identity:57`

An identity matrix, representing a null transformation.

### `shadow`

Shadow

Defined in `shadow:128`

Property representing the shadow that will be applied to a display object. This is not part of matrix operations, but is used for operations like getConcatenatedMatrix to provide concatenated shadow values.

### `tx`

Number

Defined in `tx:106`

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

### `ty`

Number

Defined in `ty:113`

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

### `visible`

Boolean

Defined in `visible:146`

Property representing the value for visible that will be applied to a display object. This is not part of matrix operations, but is used for operations like getConcatenatedMatrix to provide concatenated visible values.