# JSDoc: Class: Matrix

# Class: Matrix

## Matrix(valuesopt)

#### new Matrix(valuesopt)

2D 3x2 transformation matrix, applied to the canvas elements. The values of the matrix are stored in a numeric array.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`values` | array | <optional> |

Source:
  - math/Matrix.js, line 13

### Methods

#### clone()

Create a new matrix object with a copy of the content of this one.

Source:
  - math/Matrix.js, line 38

#### compose(px, py, sx, sy, ox, oy, a)

Compose this transformation matrix with position scale and rotation and origin point.

##### Parameters:

Name | Type | Description
--- | --- | ---
`px` | number | Position X
`py` | number | Position Y
`sx` | number | Scale X
`sy` | number | Scale Y
`ox` | number | Origin X (applied before scale and rotation)
`oy` | number | Origin Y (applied before scale and rotation)
`a` | number | Rotation angle (radians).

Source:
  - math/Matrix.js, line 96

#### copy(mat)

Copy the content of another matrix and store in this one.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mat` | Matrix |

Source:
  - math/Matrix.js, line 30

#### determinant()

Get the matrix determinant.

Source:
  - math/Matrix.js, line 208

#### getInverse()

Get the inverse matrix.

Source:
  - math/Matrix.js, line 216

#### getPosition() → {Vector2}

Get the position from the transformation matrix.

Source:
  - math/Matrix.js, line 192

##### Returns:

Position of the matrix transformation.

Type
  Vector2

#### getScale() → {Vector2}

Get the scale from the transformation matrix.

Source:
  - math/Matrix.js, line 182

##### Returns:

Scale of the matrix transformation.

Type
  Vector2

#### identity()

Reset this matrix to indentity.

Source:
  - math/Matrix.js, line 46

#### multiply(mat)

Multiply another matrix by this one and store the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mat` | Matrix |

Source:
  - math/Matrix.js, line 56

#### premultiply(mat)

Premultiply another matrix by this one and store the result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`mat` | Matrix |

Source:
  - math/Matrix.js, line 73

#### rotate(angle)

Apply rotation to this matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`angle` | number | Angle in radians.

Source:
  - math/Matrix.js, line 135

#### scale(sx, sy)

Apply scale to this matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`sx` | number |
`sy` | number |

Source:
  - math/Matrix.js, line 157

#### setContextTransform()

Set a canvas context to use this transformation.

Source:
  - math/Matrix.js, line 237

#### setPosition(x, y)

Set the position of the transformation matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number |
`y` | number |

Source:
  - math/Matrix.js, line 171

#### skew()

Apply skew to this matrix.

Source:
  - math/Matrix.js, line 200

#### tranformContext()

Transform on top of the current context transformation.

Source:
  - math/Matrix.js, line 245

#### transformPoint()

Transform a point using this matrix.

Source:
  - math/Matrix.js, line 226

#### translate(x, y)

Apply translation to this matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number |
`y` | number |

Source:
  - math/Matrix.js, line 124