Expand description
Flattened, matrix-transformed path edge table.
XPath is the Rust equivalent of SplashXPath from splash/SplashXPath.h/.cc.
It converts a Path (in user space) into a sorted sequence of line segments
in device space, ready for scan conversion by crate::XPathScanner.
§Typical usage pipeline
XPath::new(path, matrix, flatness, close_subpaths) ← construction
│ internally calls add_segment for every flattened edge
▼
XPath ← device-space edge table
│ optionally:
▼
xpath.aa_scale() ← scale coords × AA_SIZE
│ must be called AT MOST ONCE, before handing to XPathScanner
▼
XPathScanner ← scan conversion§Key invariants (established by XPath::add_segment — internal)
- For every non-horizontal segment,
y0 ≤ y1after construction (swapped if necessary;XPathFlags::FLIPPEDis set when a swap occurred). XPathFlags::HORIZis set wheny0 == y1(despite the misleading “vertical” comment in the original C++ header — trust the code).XPathFlags::VERTis set whenx0 == x1.dxdy = (x1-x0)/(y1-y0)for sloped segments; 0.0 for horizontal/vertical. Division is safe because the HORIZ early-return guaranteesy0 ≠ y1for any segment that reaches the slope computation.
§Affine transform convention
x_out = x_in * m[0] + y_in * m[2] + m[4]
y_out = x_in * m[1] + y_in * m[3] + m[5](column-vector convention matching SplashXPath::transform.)
Structs§
- XPath
- Matrix-transformed, flattened edge table derived from a
Path. - XPath
Flags - Per-segment flags for
XPathSeg. - XPath
Seg - A single line segment in the edge table, in device space.