Skip to main content

Module line

Module line 

Source
Expand description

Strokes: what a line node draws.

A line is a run of points and a Stroke; the core flattens a curve into a polyline here, boxes the run, and emits one crate::QuadKind::Segment per straight piece. The points live in a per-frame list beside the tree — rebuilt every frame, capacities kept — and a node refers to its run by LineId the way a text node refers to the frame’s text list. The previous frame’s list is kept by the same gated buffer swap the text list uses, so a departing line can copy its points out for its ghost.

Structs§

Cut
What a dashed stroke is cut by: the centre-line lengths of the pattern’s four entries — mark, gap, mark, gap — and where in it the stroke starts, 0 <= offset < period. Logical px.
Dash
A stroke’s dash pattern (backlog V2): a mark, a gap, a second mark and a second gap, repeated along the stroke’s length from its first point.
LineId
Index into the frame’s line list.
LineStore
The frame’s strokes, and the previous frame’s while an exit needs it.
Stroke
How a line is drawn: a width, a colour, and whether the points are the corners of a polyline or the knots of a curve through them.

Constants§

CURVE_MAX_PIECES
CURVE_STEP
A curve span is flattened into one piece per this many logical px of chord, at least one and at most CURVE_MAX_PIECES. Fixed rather than tolerance-driven so the piece count is a function of the declared geometry alone — every binding gets the same segments, and the conformance corpus can pin them.
MAX_MARKS
The most marks one stroke is cut into; a pattern that would make more — a period of a pixel along a line no screen is long enough for — draws solid, which is what it would read as.

Functions§

flatten_curve
Flattens a centripetal Catmull-Rom spline through knots (at least three) into out, starting at the first knot and ending at the last. Each span is cut into ceil(chord / CURVE_STEP) pieces, clamped to 1..=CURVE_MAX_PIECES.