pub struct XPath {
pub segs: Vec<XPathSeg>,
/* private fields */
}Expand description
Matrix-transformed, flattened edge table derived from a Path.
§Construction pipeline
- Call
XPath::newto build the edge table from aPath. - Optionally call
XPath::aa_scaleonce to scale coordinates byAA_SIZEfor supersampled anti-aliasing. - Hand the resulting
XPathtoXPathScannerfor scan conversion.
Calling aa_scale more than once will multiply coordinates by AA_SIZE
again, producing incorrect results. This is not checked at runtime.
Fields§
§segs: Vec<XPathSeg>The flattened, transformed edge segments making up this path, in insertion order.
Implementations§
Source§impl XPath
impl XPath
Sourcepub fn new(
path: &Path,
matrix: &[f64; 6],
flatness: f64,
close_subpaths: bool,
) -> Self
pub fn new( path: &Path, matrix: &[f64; 6], flatness: f64, close_subpaths: bool, ) -> Self
Build an XPath from a Path by applying matrix and flattening curves.
§Arguments
path: the source path in user (pre-transform) space.matrix: a 2-D affine transform[a, b, c, d, e, f]mapping user space to device space (column-vector convention; see module docs).flatness: maximum chord deviation (in device pixels) for Bezier subdivision. Smaller values produce more accurate curves but more segments. Typical range:0.1–1.0.close_subpaths: iftrue, an implicit closing segment is added from the last point of each subpath back to its first point when they do not already coincide (matchesSplashXPathconstructor behaviour).
§Ordering constraints
After this call, segs is in insertion order (one entry per flattened
edge). No further sorting is performed here; callers that need a sorted
edge table must sort segs themselves or use XPathScanner.
Calling XPath::aa_scale after this method scales all coordinates by
AA_SIZE. It must be called at most once.
Sourcepub fn aa_scale(&mut self)
pub fn aa_scale(&mut self)
Scale all segment coordinates by AA_SIZE for supersampled anti-aliasing.
dxdy (the slope) is invariant under uniform scaling and is not modified —
a uniform scale cancels out in (x1-x0)/(y1-y0).
Matches SplashXPath::aaScale().
§Ordering constraint
This method must be called after XPath::new and at most once.
Calling it a second time multiplies coordinates by AA_SIZE again,
which will produce incorrect scan-conversion results. There is no runtime
guard against double-scaling.
§Panics
Does not panic in practice. However, if any coordinate is so large that
multiplying by AA_SIZE would overflow to f64::INFINITY, subsequent
scan-conversion arithmetic will silently produce wrong results. A
debug_assert! fires in debug builds if any coordinate is non-finite
before scaling.