@mocanvas/mocanvas · function
declare function transformPathWords(words: readonly number[], mat: MatLike): number[]A copy of a flat path with mat applied to every point.
mocanvas has no PathBuilder: a shape's outline is a Geometry2d,
and the *encoded* form every consumer of an outline shares is the engine's
flat word stream (geometry.toPathWords()), which is what
pathWordsToSvgD serializes and what the indicator layer strokes. So
this is where a path transform belongs — one function, applied to the one
encoding, rather than a second path abstraction that would have to be kept
in step with the first.
``ts
const flipped = transformPathWords(geometry.toPathWords(), Mat.Identity().translate(w, 0).scale(-1, 1))
const d = pathWordsToSvgD(flipped)
``
The input is never mutated. Control points transform with their anchors, so a curve stays a curve (an affine map takes a cubic bézier to a cubic bézier); a malformed stream is truncated at the bad word, exactly as pathWordsToSvgD truncates it.
Mentioned here
mocanvas 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.