Class: Matrix

PIXI.Matrix

The PixiJS Matrix as a class makes it a lot faster.

Here is a representation of it:

| a | c | tx|
| b | d | ty|
| 0 | 0 | 1 |

new PIXI.Matrix (a, b, c, d, tx, ty)

Matrix.ts:30
Name Type Attributes Default Description
a number <optional>
1

x scale

b number <optional>
0

y skew

c number <optional>
0

x skew

d number <optional>
1

y scale

tx number <optional>
0

x translation

ty number <optional>
0

y translation

Members

PIXI.Matrix.IDENTITY PIXI.Matrix static

A default (identity) matrix

PIXI.Matrix.TEMP_MATRIX PIXI.Matrix static

A temp matrix

a number

Default Value:
  • 1

b number

Default Value:
  • 0

c number

Default Value:
  • 0

d number

Default Value:
  • 1

tx number

Default Value:
  • 0

ty number

Default Value:
  • 0

Methods

append (matrix) PIXI.Matrix

Matrix.ts:270

Appends the given Matrix to this Matrix.

Name Type Description
matrix PIXI.Matrix

The matrix to append.

Returns:
Type Description
PIXI.Matrix This matrix. Good for chaining method calls.

apply (pos, newPos) PIXI.Point

Matrix.ts:167

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 PIXI.IPointData

The origin

newPos PIXI.Point <optional>

The point that the new position is assigned to (allowed to be same as input)

Returns:
Type Description
PIXI.Point The new point, transformed through this matrix

applyInverse (pos, newPos) PIXI.Point

Matrix.ts:188

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 PIXI.IPointData

The origin

newPos PIXI.Point <optional>

The point that the new position is assigned to (allowed to be same as input)

Returns:
Type Description
PIXI.Point The new point, inverse-transformed through this matrix

clone () PIXI.Matrix

Matrix.ts:433

Creates a new Matrix object with the same values as this one.

Returns:
Type Description
PIXI.Matrix A copy of this matrix. Good for chaining method calls.

copyFrom (matrix) PIXI.Matrix

Matrix.ts:470

Changes the values of the matrix to be the same as the ones in given matrix

Name Type Description
matrix PIXI.Matrix

The matrix to copy from.

Returns:
Type Description
PIXI.Matrix this

copyTo (matrix) PIXI.Matrix

Matrix.ts:452

Changes the values of the given matrix to be the same as the ones in this matrix

Name Type Description
matrix PIXI.Matrix

The matrix to copy to.

Returns:
Type Description
PIXI.Matrix The matrix given in parameter with its values updated.

decompose (transform) PIXI.Transform

Matrix.ts:349

Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.

Name Type Description
transform PIXI.Transform

The transform to apply the properties to.

Returns:
Type Description
PIXI.Transform The transform with the newly applied properties

fromArray (array) void

Matrix.ts:77

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 Array<number>

The array that the matrix will be populated from.

identity () PIXI.Matrix

Matrix.ts:416

Resets this Matrix to an identity (default) matrix.

Returns:
Type Description
PIXI.Matrix This matrix. Good for chaining method calls.

invert () PIXI.Matrix

Matrix.ts:392

Inverts this matrix

Returns:
Type Description
PIXI.Matrix This matrix. Good for chaining method calls.

prepend (matrix) PIXI.Matrix

Matrix.ts:322

Prepends the given Matrix to this Matrix.

Name Type Description
matrix PIXI.Matrix

The matrix to prepend

Returns:
Type Description
PIXI.Matrix This matrix. Good for chaining method calls.

rotate (angle) PIXI.Matrix

Matrix.ts:245

Applies a rotation transformation to the matrix.

Name Type Description
angle number

The angle in radians.

Returns:
Type Description
PIXI.Matrix This matrix. Good for chaining method calls.

scale (x, y) PIXI.Matrix

Matrix.ts:226

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
PIXI.Matrix This matrix. Good for chaining method calls.

set (a, b, c, d, tx, ty) PIXI.Matrix

Matrix.ts:99

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
PIXI.Matrix This matrix. Good for chaining method calls.

setTransform (x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) PIXI.Matrix

Matrix.ts:294

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
PIXI.Matrix This matrix. Good for chaining method calls.

toArray (transpose, out) Array<number>

Matrix.ts:123

Creates an array from the current Matrix object.

Name Type Attributes Default Description
transpose boolean

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
Array<number> the newly created array which contains the matrix

translate (x, y) PIXI.Matrix

Matrix.ts:211

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
PIXI.Matrix This matrix. Good for chaining method calls.