A Matrix used for display transformations for rendering.
It is represented like so:
| a | c | tx |
| b | d | ty |
| 0 | 0 | 1 |
new TransformMatrix([a], [b], [c], [d], [tx], [ty])
name | type | arguments | Default | description |
---|---|---|---|---|
a | number | <optional> | 1 |
The Scale X value. |
b | number | <optional> | 0 |
The Skew Y value. |
c | number | <optional> | 0 |
The Skew X value. |
d | number | <optional> | 1 |
The Scale Y value. |
tx | number | <optional> | 0 |
The Translate X value. |
ty | number | <optional> | 0 |
The Translate Y value. |
The Scale X value.
The Skew Y value.
The Skew X value.
The Scale Y value.
The decomposed matrix.
The Translate X value.
The Translate Y value.
The matrix values.
The temporary quad value cache.
The rotation of the Matrix. Value is in radians.
The rotation of the Matrix, normalized to be within the Phaser right-handed clockwise rotation space. Value is in radians.
The decomposed horizontal scale of the Matrix. This value is always positive.
The decomposed vertical scale of the Matrix. This value is always positive.
The Translate X value.
The Translate Y value.
Apply the identity, translate, rotate and scale operations on the Matrix.
name | type | description |
---|---|---|
x | number |
The horizontal translation. |
y | number |
The vertical translation. |
rotation | number |
The angle of rotation in radians. |
scaleX | number |
The horizontal scale. |
scaleY | number |
The vertical scale. |
This TransformMatrix.
Takes the x
and y
values and returns a new position in the output
vector that is the inverse of
the current matrix with its transformation applied.
Can be used to translate points from world to local space.
name | type | arguments | description |
---|---|---|---|
x | number |
The x position to translate. |
|
y | number |
The y position to translate. |
|
output | Phaser.Math.Vector2 | <optional> |
A Vector2, or point-like object, to store the results in. |
The coordinates, inverse-transformed through this matrix.
Set the values of this Matrix to copy those of the matrix given.
name | type | description |
---|---|---|
src | Phaser.GameObjects.Components.TransformMatrix |
The source Matrix to copy from. |
This TransformMatrix.
Set the values of this Matrix to copy those of the array given. Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.
name | type | description |
---|---|---|
src | array |
The array of values to set into this matrix. |
This TransformMatrix.
Copy the values in this Matrix to the array given.
Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.
name | type | arguments | description |
---|---|---|---|
out | array | <optional> |
The array to copy the matrix values in to. |
An array where elements 0 to 5 contain the values from this matrix.
Copy the values from this Matrix to the given Canvas Rendering Context. This will use the Context.transform method.
name | type | description |
---|---|---|
ctx | CanvasRenderingContext2D |
The Canvas Rendering Context to copy the matrix values to. |
The Canvas Rendering Context.
Decompose this Matrix into its translation, scale and rotation values using QR decomposition.
The result must be applied in the following order to reproduce the current matrix:
translate -> rotate -> scale
The decomposed Matrix.
Destroys this Transform Matrix.
Returns a string that can be used in a CSS Transform call as a matrix
property.
A string containing the CSS Transform matrix values.
Returns the X component of this matrix multiplied by the given values.
This is the same as x * a + y * c + e
.
name | type | description |
---|---|---|
x | number |
The x value. |
y | number |
The y value. |
The calculated x value.
Returns the X component of this matrix multiplied by the given values.
This is the same as x * a + y * c + e
, optionally passing via Math.round
.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x value. |
||
y | number |
The y value. |
||
round | boolean | <optional> | false |
Math.round the resulting value? |
The calculated x value.
Returns the Y component of this matrix multiplied by the given values.
This is the same as x * b + y * d + f
.
name | type | description |
---|---|---|
x | number |
The x value. |
y | number |
The y value. |
The calculated y value.
Returns the Y component of this matrix multiplied by the given values.
This is the same as x * b + y * d + f
, optionally passing via Math.round
.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x value. |
||
y | number |
The y value. |
||
round | boolean | <optional> | false |
Math.round the resulting value? |
The calculated y value.
Invert the Matrix.
This TransformMatrix.
Reset the Matrix to an identity matrix.
This TransformMatrix.
Multiply this Matrix by the given Matrix.
If an out
Matrix is given then the results will be stored in it.
If it is not given, this matrix will be updated in place instead.
Use an out
Matrix if you do not wish to mutate this matrix.
name | type | arguments | description |
---|---|---|---|
rhs | Phaser.GameObjects.Components.TransformMatrix |
The Matrix to multiply by. |
|
out | Phaser.GameObjects.Components.TransformMatrix | <optional> |
An optional Matrix to store the results in. |
Either this TransformMatrix, or the out
Matrix, if given in the arguments.
Multiply this Matrix by the matrix given, including the offset.
The offsetX is added to the tx value: offsetX * a + offsetY * c + tx
.
The offsetY is added to the ty value: offsetY * b + offsetY * d + ty
.
name | type | description |
---|---|---|
src | Phaser.GameObjects.Components.TransformMatrix |
The source Matrix to copy from. |
offsetX | number |
Horizontal offset to factor in to the multiplication. |
offsetY | number |
Vertical offset to factor in to the multiplication. |
This TransformMatrix.
Rotate the Matrix.
name | type | description |
---|---|---|
angle | number |
The angle of rotation in radians. |
This TransformMatrix.
Scale the Matrix.
name | type | description |
---|---|---|
x | number |
The horizontal scale value. |
y | number |
The vertical scale value. |
This TransformMatrix.
Performs the 8 calculations required to create the vertices of a quad based on this matrix and the given x/y/xw/yh values.
The result is stored in TransformMatrix.quad
, which is returned
from this method.
name | type | arguments | Default | description |
---|---|---|---|---|
x | number |
The x value. |
||
y | number |
The y value. |
||
xw | number |
The xw value. |
||
yh | number |
The yh value. |
||
roundPixels | boolean | <optional> | false |
Pass the results via Math.round? |
quad | Float32Array | <optional> |
Optional Float32Array to store the results in. Otherwises uses the local quad array. |
The quad Float32Array.
Copy the values from this Matrix to the given Canvas Rendering Context. This will use the Context.setTransform method.
name | type | description |
---|---|---|
ctx | CanvasRenderingContext2D |
The Canvas Rendering Context to copy the matrix values to. |
The Canvas Rendering Context.
Set the values of this Matrix.
name | type | description |
---|---|---|
a | number |
The Scale X value. |
b | number |
The Shear Y value. |
c | number |
The Shear X value. |
d | number |
The Scale Y value. |
tx | number |
The Translate X value. |
ty | number |
The Translate Y value. |
This TransformMatrix.
Transform the Matrix.
name | type | description |
---|---|---|
a | number |
The Scale X value. |
b | number |
The Shear Y value. |
c | number |
The Shear X value. |
d | number |
The Scale Y value. |
tx | number |
The Translate X value. |
ty | number |
The Translate Y value. |
This TransformMatrix.
Transform a point in to the local space of this Matrix.
name | type | arguments | description |
---|---|---|---|
x | number |
The x coordinate of the point to transform. |
|
y | number |
The y coordinate of the point to transform. |
|
point | Phaser.Types.Math.Vector2Like | <optional> |
Optional Point object to store the transformed coordinates in. |
The Point containing the transformed coordinates.
Translate the Matrix.
name | type | description |
---|---|---|
x | number |
The horizontal translation value. |
y | number |
The vertical translation value. |
This TransformMatrix.