Skip to main content

Module path

Module path 

Source
Expand description

PDF path geometry: points, flags, subpath state machine, and builder API.

The pts and flags arrays are parallel SoA (one entry per index). This layout originates in SplashPath from splash/SplashPath.{h,cc}, but is preserved deliberately rather than ported: xpath::XPath::new transforms the entire pts array under a CTM in one pass before anything reads flags, and the contiguous f64-pair layout keeps that pre-pass tight. Walkers that read both arrays together (xpath.rs, stroke/path.rs) pay one extra L1-resident byte per index, which is negligible.

§Subpath state machine

A Path is always in one of three states (matching the C++ comments in SplashPath.cc):

StateConditionMeaning
No current pointcur_subpath == pts.len()Fresh path or just after close
One-point subpathcur_subpath == pts.len() - 1After moveTo, before lineTo
Open subpathcur_subpath < pts.len() - 1Active path with ≥ 2 points

The one_point_subpath and open_subpath predicates both guard against pts.is_empty() before comparing with pts.len() - 1, so neither can underflow on an empty vector.

Modules§

adjust
Stroke-adjust hint application.
flatten
Adaptive Bezier curve flattening via De Casteljau subdivision.

Structs§

Path
A PDF graphics path: an ordered sequence of subpaths built from lines and cubic Bezier curves.
PathBuilder
Ergonomic builder for Path implementing the PDF path construction operators (m, l, c, h) with the same state-machine semantics as SplashPath::moveTo / lineTo / curveTo / close.
PathFlags
Per-point flags stored in the parallel flags array of a Path.
PathPoint
A 2-D point in path space (f64 coordinates, matching SplashPathPoint).
StrokeAdjustHint
Stroke-adjust hint: a pair of path segments that should be snapped to integer pixel boundaries to avoid seams between adjacent filled rectangles.

Enums§

PathError
Errors returned by PathBuilder construction methods.