Name | Type | Default | Description |
---|---|---|---|
a |
number | 1 |
x scale |
b |
number | 0 |
y skew |
c |
number | 0 |
x skew |
d |
number | 1 |
y scale |
tx |
number | 0 |
x translation |
ty |
number | 0 |
y translation |
Members
IDENTITY Readonly<Matrix> staticreadonly
A default (identity) matrix
shared Matrix staticreadonly
A static Matrix that can be used to avoid creating new objects. Will always ensure the matrix is reset to identity when requested.
- Default Value:
- 1
An array of the current matrix. Only populated when toArray
is called
- Default Value:
- undefined
- Default Value:
- 0
- Default Value:
- 0
- Default Value:
- 1
- Default Value:
- 0
- Default Value:
- 0
Methods
Appends the given Matrix to this Matrix.
Name | Type | Description |
---|---|---|
matrix |
Matrix |
The matrix to append. |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Appends two matrix's and sets the result to this matrix. AB = A * B
Name | Type | Description |
---|---|---|
a |
Matrix |
The matrix to append. |
b |
Matrix |
The matrix to append. |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Get a new position with the current transformation applied. Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
Name | Type | Attributes | Description |
---|---|---|---|
pos |
PointData |
The origin |
|
newPos |
Point |
<optional> |
The point that the new position is assigned to (allowed to be same as input) |
Returns:
Type | Description |
---|---|
Point | The new point, transformed through this matrix |
Get a new position with the inverse of the current transformation applied. Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
Name | Type | Attributes | Description |
---|---|---|---|
pos |
PointData |
The origin |
|
newPos |
Point |
<optional> |
The point that the new position is assigned to (allowed to be same as input) |
Returns:
Type | Description |
---|---|
Point | The new point, inverse-transformed through this matrix |
clone () Matrix
Creates a new Matrix object with the same values as this one.
Returns:
Type | Description |
---|---|
Matrix | A copy of this matrix. Good for chaining method calls. |
Changes the values of the matrix to be the same as the ones in given matrix
Name | Type | Description |
---|---|---|
matrix |
Matrix |
The matrix to copy from. |
Returns:
Type | Description |
---|---|
this | this |
copyTo (matrix) Matrix
Changes the values of the given matrix to be the same as the ones in this matrix
Name | Type | Description |
---|---|---|
matrix |
Matrix |
The matrix to copy to. |
Returns:
Type | Description |
---|---|
Matrix | The matrix given in parameter with its values updated. |
decompose (transform) Transform
Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
Name | Type | Description |
---|---|---|
transform |
Transform |
The transform to apply the properties to. |
Returns:
Type | Description |
---|---|
Transform | The transform with the newly applied properties |
Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
a = array[0] b = array[1] c = array[3] d = array[4] tx = array[2] ty = array[5]
Name | Type | Description |
---|---|---|
array |
number[] |
The array that the matrix will be populated from. |
Resets this Matrix to an identity (default) matrix.
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Inverts this matrix
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Checks if this matrix is an identity matrix
Returns:
Type | Description |
---|---|
boolean |
Prepends the given Matrix to this Matrix.
Name | Type | Description |
---|---|---|
matrix |
Matrix |
The matrix to prepend |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Applies a rotation transformation to the matrix.
Name | Type | Description |
---|---|---|
angle |
number |
The angle in radians. |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Applies a scale transformation to the matrix.
Name | Type | Description |
---|---|---|
x |
number |
The amount to scale horizontally |
y |
number |
The amount to scale vertically |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Sets the matrix properties.
Name | Type | Description |
---|---|---|
a |
number |
Matrix component |
b |
number |
Matrix component |
c |
number |
Matrix component |
d |
number |
Matrix component |
tx |
number |
Matrix component |
ty |
number |
Matrix component |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Sets the matrix based on all the available properties
Name | Type | Description |
---|---|---|
x |
number |
Position on the x axis |
y |
number |
Position on the y axis |
pivotX |
number |
Pivot on the x axis |
pivotY |
number |
Pivot on the y axis |
scaleX |
number |
Scale on the x axis |
scaleY |
number |
Scale on the y axis |
rotation |
number |
Rotation in radians |
skewX |
number |
Skew on the x axis |
skewY |
number |
Skew on the y axis |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |
Creates an array from the current Matrix object.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
transpose |
boolean |
<optional> |
Whether we need to transpose the matrix or not |
|
out |
Float32Array |
<optional> |
new Float32Array(9) |
If provided the array will be assigned to out |
Returns:
Type | Description |
---|---|
Float32Array | The newly created array which contains the matrix |
Translates the matrix on the x and y.
Name | Type | Description |
---|---|---|
x |
number |
How much to translate x by |
y |
number |
How much to translate y by |
Returns:
Type | Description |
---|---|
this | This matrix. Good for chaining method calls. |