Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
interface Matrix3x3Helpers
import { type Matrix3x3Helpers } from "https://deno.land/x/canvaseno@v1.0.2/mod.ts";

TODO(kjlubick) Make this API return Float32Arrays

Methods

identity(): number[]

Returns a new identity 3x3 matrix.

invert(m: Matrix3x3 | number[]): number[] | null

Returns the inverse of the given 3x3 matrix or null if it is not invertible.

mapPoints(m: Matrix3x3 | number[], points: number[]): number[]

Maps the given 2d points according to the given 3x3 matrix.

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

Multiplies the provided 3x3 matrices together from left to right.

rotated(
radians: AngleInRadians,
px?: number,
py?: number,
): number[]

Returns a new 3x3 matrix representing a rotation by n radians.

scaled(
sx: number,
sy: number,
px?: number,
py?: number,
): number[]

Returns a new 3x3 matrix representing a scale in the x and y directions.

skewed(
kx: number,
ky: number,
px?: number,
py?: number,
): number[]

Returns a new 3x3 matrix representing a scale in the x and y directions.

translated(dx: number, dy: number): number[]

Returns a new 3x3 matrix representing a translation in the x and y directions.