Module

x/canvas/mod.ts>Matrix4x4Helpers

Canvas API for Deno, ported from canvaskit-wasm (Skia).
Go to Latest
interface Matrix4x4Helpers
import { type Matrix4x4Helpers } from "https://deno.land/x/canvas@v1.0.0/mod.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: Vector3,
centerVec: Vector3,
upVec: Vector3,
): 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,
radians: AngleInRadians,
): 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.

rotated(axis: Vector3, radians: AngleInRadians): number[]

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

rotatedUnitSinCos(
axis: Vector3,
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: Vector3): number[]

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

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

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

translated(vec: Vector3): 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.