Skip to content

API Reference / @gtkx/cairo / Matrix

Class: Matrix ​

Defined in: matrix.d.ts:13

An affine transformation (cairo_matrix_t) mapping user space to device space: x' = xx * x + xy * y + x0 and y' = yx * x + yy * y + y0.

Constructors ​

Constructor ​

new Matrix(xx, yx, xy, yy, x0, y0): Matrix

Defined in: matrix.d.ts:25

Creates a matrix from its six affine components.

Parameters ​

xx ​

number

yx ​

number

xy ​

number

yy ​

number

x0 ​

number

y0 ​

number

Returns ​

Matrix

Methods ​

invert() ​

invert(): Status

Defined in: matrix.d.ts:33

Replaces the matrix with its inverse, returning Status.INVALID_MATRIX when it has none.

Returns ​

Status


rotate() ​

rotate(radians): void

Defined in: matrix.d.ts:31

Applies a rotation by radians before the existing transformation.

Parameters ​

radians ​

number

Returns ​

void


scale() ​

scale(sx, sy): void

Defined in: matrix.d.ts:29

Applies a scaling by sx and sy before the existing transformation.

Parameters ​

sx ​

number

sy ​

number

Returns ​

void


transformDistance() ​

transformDistance(dx, dy): Distance

Defined in: matrix.d.ts:37

Transforms the distance vector (dx, dy), ignoring translation.

Parameters ​

dx ​

number

dy ​

number

Returns ​

Distance


transformPoint() ​

transformPoint(x, y): Point

Defined in: matrix.d.ts:35

Transforms the point (x, y), translation included.

Parameters ​

x ​

number

y ​

number

Returns ​

Point


translate() ​

translate(tx, ty): void

Defined in: matrix.d.ts:27

Applies a translation by tx and ty before the existing transformation.

Parameters ​

tx ​

number

ty ​

number

Returns ​

void


initIdentity() ​

static initIdentity(): Matrix

Defined in: matrix.d.ts:15

Returns the identity transformation.

Returns ​

Matrix


initRotate() ​

static initRotate(radians): Matrix

Defined in: matrix.d.ts:21

Returns a transformation rotating by radians, positive angles turning from the X axis toward the Y axis.

Parameters ​

radians ​

number

Returns ​

Matrix


initScale() ​

static initScale(sx, sy): Matrix

Defined in: matrix.d.ts:19

Returns a transformation scaling by sx and sy.

Parameters ​

sx ​

number

sy ​

number

Returns ​

Matrix


initTranslate() ​

static initTranslate(tx, ty): Matrix

Defined in: matrix.d.ts:17

Returns a transformation translating by tx and ty.

Parameters ​

tx ​

number

ty ​

number

Returns ​

Matrix


multiply() ​

static multiply(a, b): Matrix

Defined in: matrix.d.ts:23

Returns the product of a and b: the transformation that applies a first, then b.

Parameters ​

a ​

Matrix

b ​

Matrix

Returns ​

Matrix