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):
| State | Condition | Meaning |
|---|---|---|
| No current point | cur_subpath == pts.len() | Fresh path or just after close |
| One-point subpath | cur_subpath == pts.len() - 1 | After moveTo, before lineTo |
| Open subpath | cur_subpath < pts.len() - 1 | Active 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.
- Path
Builder - Ergonomic builder for
Pathimplementing the PDF path construction operators (m,l,c,h) with the same state-machine semantics asSplashPath::moveTo/lineTo/curveTo/close. - Path
Flags - Per-point flags stored in the parallel
flagsarray of aPath. - Path
Point - A 2-D point in path space (f64 coordinates, matching
SplashPathPoint). - Stroke
Adjust Hint - Stroke-adjust hint: a pair of path segments that should be snapped to integer pixel boundaries to avoid seams between adjacent filled rectangles.
Enums§
- Path
Error - Errors returned by
PathBuilderconstruction methods.