Options for the transform.
Options for the Transform constructor.
The pivot point of the container that it rotates around.
The coordinate of the object relative to the local coordinates of the parent.
The scale factor of the object.
The skew amount, on the x and y axis.
The transformation matrix computed from the transform's properties. Combines position, scale, rotation, skew, and pivot into a single matrix.
The rotation of the object in radians.
// Basic rotation
transform.rotation = Math.PI / 4; // 45 degrees
// Rotate around pivot point
transform.pivot.set(50, 50);
transform.rotation = Math.PI; // 180 degrees around pivot
// Animate rotation
app.ticker.add(() => {
transform.rotation += 0.1;
});
Decomposes a matrix and sets the transforms properties based on it.
The matrix to decompose
// Basic matrix decomposition
const transform = new Transform();
const matrix = new Matrix()
.translate(100, 100)
.rotate(Math.PI / 4)
.scale(2, 2);
transform.setFromMatrix(matrix);
console.log(transform.position.x); // 100
console.log(transform.rotation); // ~0.785 (π/4)
The Transform class facilitates the manipulation of a 2D transformation matrix through user-friendly properties: position, scale, rotation, skew, and pivot.
Example
Remarks
See