new Tiny.Matrix(a, b, c, d, tx, ty)
| Name | Type | Default | Description |
|---|---|---|---|
a |
number | 1 |
optional
x scale |
b |
number | 0 |
optional
y skew |
c |
number | 0 |
optional
x skew |
d |
number | 1 |
optional
y scale |
tx |
number | 0 |
optional
x translation |
ty |
number | 0 |
optional
y translation |
Members
-
static,constantTiny.Matrix.IDENTITY
-
A default (identity) matrix
-
static,constantTiny.Matrix.TEMP_MATRIX
-
A temp matrix
-
anumber
-
- Default Value:
- 1
-
bnumber
-
- Default Value:
- 0
-
cnumber
-
- Default Value:
- 0
-
dnumber
-
- Default Value:
- 1
-
txnumber
-
- Default Value:
- 0
-
tynumber
-
- Default Value:
- 0
Methods
-
append(matrix) ❯ {Tiny.Matrix}
-
Appends the given Matrix to this Matrix.
Name Type Description matrixTiny.Matrix The matrix to append.
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
apply(pos, newPos) ❯ {Tiny.Point}
-
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 Description posTiny.Point The origin
newPosTiny.Point optional The point that the new position is assigned to (allowed to be same as input)
Returns:
Type Description Tiny.Point The new point, transformed through this matrix -
applyInverse(pos, newPos) ❯ {Tiny.Point}
-
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 Description posTiny.Point The origin
newPosTiny.Point optional The point that the new position is assigned to (allowed to be same as input)
Returns:
Type Description Tiny.Point The new point, inverse-transformed through this matrix -
clone() ❯ {Tiny.Matrix}
-
Creates a new Matrix object with the same values as this one.
Returns:
Type Description Tiny.Matrix A copy of this matrix. Good for chaining method calls. -
copy(matrix) ❯ {Tiny.Matrix}
-
Changes the values of the given matrix to be the same as the ones in this matrix
Name Type Description matrixTiny.Matrix The matrix to copy from.
Returns:
Type Description Tiny.Matrix The matrix given in parameter with its values updated. -
decompose(transform) ❯ {Tiny.Transform|Tiny.TransformStatic}
-
Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
Name Type Description transformTiny.Transform | Tiny.TransformStatic The transform to apply the properties to.
Returns:
Type Description Tiny.Transform | Tiny.TransformStatic The transform with the newly applied properties -
fromArray(array)
-
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 arrayArray.<number> The array that the matrix will be populated from.
-
identity() ❯ {Tiny.Matrix}
-
Resets this Matix to an identity (default) matrix.
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
invert() ❯ {Tiny.Matrix}
-
Inverts this matrix
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
prepend(matrix) ❯ {Tiny.Matrix}
-
Prepends the given Matrix to this Matrix.
Name Type Description matrixTiny.Matrix The matrix to prepend
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
rotate(angle) ❯ {Tiny.Matrix}
-
Applies a rotation transformation to the matrix.
Name Type Description anglenumber The angle in radians.
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
scale(x, y) ❯ {Tiny.Matrix}
-
Applies a scale transformation to the matrix.
Name Type Description xnumber The amount to scale horizontally
ynumber The amount to scale vertically
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
set(a, b, c, d, tx, ty) ❯ {Tiny.Matrix}
-
sets the matrix properties
Name Type Description anumber Matrix component
bnumber Matrix component
cnumber Matrix component
dnumber Matrix component
txnumber Matrix component
tynumber Matrix component
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) ❯ {Tiny.Matrix}
-
Sets the matrix based on all the available properties
Name Type Description xnumber Position on the x axis
ynumber Position on the y axis
pivotXnumber Pivot on the x axis
pivotYnumber Pivot on the y axis
scaleXnumber Scale on the x axis
scaleYnumber Scale on the y axis
rotationnumber Rotation in radians
skewXnumber Skew on the x axis
skewYnumber Skew on the y axis
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls. -
toArray(transpose, out) ❯ {Array.<number>}
-
Creates an array from the current Matrix object.
Name Type Default Description transposeboolean Whether we need to transpose the matrix or not
outFloat32Array new Float32Array(9) optional If provided the array will be assigned to out
Returns:
Type Description Array.<number> the newly created array which contains the matrix -
translate(x, y) ❯ {Tiny.Matrix}
-
Translates the matrix on the x and y.
Name Type Description xnumber How much to translate x by
ynumber How much to translate y by
Returns:
Type Description Tiny.Matrix This matrix. Good for chaining method calls.