Skip to main content

Module path

Module path 

Source
Expand description

An authored silhouette, parsed from inline SVG path data (ADR-0107).

Every other silhouette this engine draws is one of five names in the marks roster. This module is the escape hatch: a [path] d = "M ... Z" string is parsed once at load into a closed contour of samples points, normalized into the same [-1, 1] box a mark lives in, and handed to the scene as ordinary structural config. Nothing here runs per frame.

§The subset, and why it has edges

Accepted: M m L l H h V v C c S s Q q T t Z z — moveto, the three line forms, cubic and quadratic Beziers with their smooth-continuation forms, and closepath. Two things are refused by name rather than approximated:

  • A/a, the elliptical arc. Its centre parameterisation is a different geometry from the Bezier forms above, and every design tool can export the same curve as cubics.
  • A second subpath. A morph aligns two contours by arc length, and two paths with different subpath counts have no natural correspondence at all — so the pair that could not be aligned is refused at the one path rather than guessed at the morph (ADR-0107).

Both refusals name what they found, because an author meeting one is holding a file a browser renders correctly.

§The y axis points down, as SVG’s does

A d string is read exactly as a browser reads it: y increases downward, so M 0,-1 is above M 0,1. The contour this module hands out is in the engine’s frame, where y increases upward, and PathShape::parse negates once during normalization to get there.

The consequence worth stating is the one an author sees: a path pasted out of a design tool renders the way that tool drew it, with no editing. Every coordinate below that point — PathShape::points, PathShape::signed_area and the morph alignment — is already y-up and needs no further flip.

§A malformed path is an error with a character offset

Not a fallback shape. A silently mis-parsed path renders as a plausible wrong figure, which reads as a design decision rather than as a mistake — so every failure carries the byte offset into d where it was found, and PathError’s Display leads with it.

§The normalization is recorded, not inferred

The contour’s own tight bounding box is centred on the origin and its longer axis scaled to exactly [-1, 1]; the centre and factor applied are kept on the PathShape. Two consequences, and the second is the point: a path authored at any scale or offset lands in the same place, so swapping one path for another does not also move the figure — the preset’s scale and pan stay the only things that do.

Structs§

PathError
Why a [path] d string could not be parsed.
PathShape
A parsed, normalized, resampled closed contour.

Enums§

PathErrorKind
What was wrong with a [path] d string.

Constants§

DEFAULT_SAMPLES
The arity a [path] resamples to when it names none.
MAX_ARC_PIECES
The most arc pieces a fitted contour may carry before the fit is discarded and the figure stays a polyline.
MAX_SAMPLES
The most points a resampled contour may carry.
MIN_SAMPLES
The fewest points a resampled contour may carry: a triangle.