@mocanvas/editor · class
declare class MatThis one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.
On this page
Methods · 37
static Absolute(m: MatLike): MatThe transform with any reflection taken out of it, so that both axes scale positively and only the rotation carries the orientation.
SEMANTICS-ASSUMED: the docs give the name and signature only. "Absolute" reading as "absolute scale" is the interpretation that makes it useful — it is what lets a mirrored shape be measured without its own flip confusing the measurement.
static applyToBounds(m: MatLike, box: BoxLike): BoxThe axis-aligned box containing box after m is applied. A rotation makes
this larger than the original — it is the bounding box of the transformed
rectangle, not the transformed rectangle.
applyToPoint(point: VecLike): VecPush a point through the transform.
applyToPoints(points: readonly VecLike[]): Vec[]static applyToXY(m: MatLike, x: number, y: number): number[]Push (x, y) through m, as a bare pair.
static Cast(m: MatLike): Matm itself when it is already a Mat, otherwise a Mat copy of it.
clone(): Matstatic Compose(...matrices: MatLike[]): MatThe product of every transform given, left to right — Compose(parent, child)
is the parent's transform followed by the child's, which is the order a
shape hierarchy composes in. With no arguments this is the identity.
constructor(a: number, b: number, c: number, d: number, e: number, f: number)decompose(): DecomposedMatstatic Decompose(m: MatLike): DecomposedMatdecomposed(): DecomposedMatAn alias of Mat.decompose.
equals(m: MatLike): booleanstatic From(m: MatLike): MatAdopt any {a,b,c,d,e,f} — including the plain literals used internally.
getRotation(): numberThe rotation this transform applies, in radians, signed.
getScale(): numberThe uniform scale this transform applies, as the mean of its two axes.
identity(): thisReset to the identity, in place.
static Identity(): Matstatic Inverse(m: MatLike): MatThe inverse of any {a…f}, as a new Mat. See Mat.invert.
invert(): thisInvert this transform in place, for going from page space back into shape
space. A singular matrix (a zero-scale shape) has no inverse; it becomes the
identity rather than a field of NaNs, so a degenerate shape maps points to
themselves instead of poisoning everything downstream.
multiply(m: MatLike): thisPost-multiply this transform by m, in place.
SEMANTICS-ASSUMED: the chainable builders (multiply, translate,
rotate, scale) mutate and return this rather than returning a copy.
The call sites are all of the form Mat.Identity().translate(x, y).rotate(r)
— a fresh matrix built up in one expression — which reads the same either
way, and mutating matches how Vec.add/Vec.mul behave. Callers holding a
matrix they did not create should clone() first.
static Multiply(m: MatLike, n: MatLike): Matm then n, i.e. the matrix product m × n.
multiplyBy(m: MatLike): thisPost-multiply this transform by m, in place.
@deprecated Use Mat.multiply, the documented name.
point(): VecThe translation component, i.e. where this transform sends the origin.
static Point(m: MatLike): VecWhere m sends the origin, i.e. its translation component.
rotate(r: number, cx?: number, cy?: number): thisRotate by r radians about this transform's own origin, or about
(cx, cy) in its own space when given. A zero angle short-circuits, so an
unrotated shape's transform stays free of cos/sin float dust.
static Rotate(r: number, cx?: number, cy?: number): MatA pure rotation, about the origin or about (cx, cy) when given.
rotation(): numberThe rotation this transform encodes, in radians, normalized to [0, 2π).
static Rotation(m: MatLike): numberThe rotation m encodes, in radians, normalized to [0, 2π).
scale(x: number, y?: number): thisScale by (x, y) in this transform's own space, in place.
static Scale(x: number, y: number): MatA pure scale.
setTo(model: MatLike): thisAdopt every component of model, in place.
static Smooth(m: MatLike, precision?: number): MatEvery component rounded, to keep float dust out of a serialized transform.
toCssString(): stringtoJson(): MatModelThe six components as a plain object.
translate(x: number, y: number): thisTranslate by (x, y) in this transform's own space, in place.
static Translate(x: number, y: number): MatA pure translation.
Properties · 6
a: numberb: numberc: numberd: numbere: numberf: numbermocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.