Module
Canvas API for Deno, ported from canvaskit-wasm (Skia).
Popular
interface Matrix4x4Helpers
``````import { type Matrix4x4Helpers } from "https://deno.land/x/canvas@v1.0.0/types.ts";
``````

See SkM44.h for more details.

## Methods

identity(): number[]

Returns a new identity 4x4 matrix.

invert(matrix: Matrix4x4 | number[]): number[] | null

Returns the inverse of the given 4x4 matrix or null if it is not invertible.

lookat(
eyeVec,
centerVec,
upVec,
): number[]

Return a new 4x4 matrix representing a camera at eyeVec, pointed at centerVec.

multiply(...matrices: Array<(Matrix4x4 | number[])>): number[]

Multiplies the provided 4x4 matrices together from left to right.

mustInvert(matrix: Matrix4x4 | number[]): number[]

Returns the inverse of the given 4x4 matrix or throws if it is not invertible.

perspective(
near: number,
far: number,
): number[]

Returns a new 4x4 matrix representing a perspective.

rc(
matrix: Matrix4x4 | number[],
row: number,
col: number,
): number

Returns the value at the specified row and column of the given 4x4 matrix.

Returns a new 4x4 matrix representing a rotation around the provided vector.

rotatedUnitSinCos(
axis,
sinAngle: number,
cosAngle: number,
): number[]

Returns a new 4x4 matrix representing a rotation around the provided vector. Rotation is provided redundantly as both sin and cos values. This rotate can be used when you already have the cosAngle and sinAngle values so you don't have to atan(cos/sin) to call roatated() which expects an angle in radians. This does no checking! Behavior for invalid sin or cos values or non-normalized axis vectors is incorrect. Prefer rotated().

scaled(vec): number[]

Returns a new 4x4 matrix representing a scale by the provided vector.

setupCamera(
area,
zScale: number,
cam,
): number[]

Returns a new 4x4 matrix that sets up a 3D perspective view from a given camera.

translated(vec): number[]

Returns a new 4x4 matrix representing a translation by the provided vector.

transpose(matrix: Matrix4x4 | number[]): number[]

Returns a new 4x4 matrix that is the transpose of this 4x4 matrix.