pub struct Path { /* private fields */ }Expand description
An immutable path: verb + point arrays (SoA), built once via PathBuilder,
shared by Arc inside display-list ops (cloning a recorded list never copies
point data). Flattening is the CALLER’s move because tolerance depends on the
device scale at draw time — a path has no scale of its own.
Implementations§
Source§impl Path
impl Path
pub fn bounds(&self) -> Rect
Sourcepub fn tight_bounds(&self) -> Rect
pub fn tight_bounds(&self) -> Rect
Exact axis-aligned bounds of the path’s lines and Bézier curves. Recording uses the cheaper control-point bounds above; queries such as Canvas text metrics use this slower extrema walk when tight ink bounds are part of the API contract.
pub fn is_empty(&self) -> bool
Sourcepub fn heap_bytes(&self) -> usize
pub fn heap_bytes(&self) -> usize
Heap footprint estimate (points dominate) — memory reports only.
Sourcepub fn contains(&self, point: Point, fill_rule: FillRule) -> bool
pub fn contains(&self, point: Point, fill_rule: FillRule) -> bool
Is point inside this path under fill_rule? The query runs on the
curves themselves rather than a flattened approximation, so the answer
does not drift with zoom. Every contour closes implicitly, matching how
fills are drawn, and a point exactly on the outline counts as inside.
“On the outline” is decided with the same ABSOLUTE tolerance Skia uses (1/4096 of a unit), so on a path whose coordinates are tiny or enormous that band is proportionally wider or narrower than it looks.
Sourcepub fn measure(&self, tolerance: f32) -> Vec<ContourMeasure>
pub fn measure(&self, tolerance: f32) -> Vec<ContourMeasure>
Measure each contour for arc length — Skia’s SkContourMeasure.
Contours with no length (a lone point) are dropped, so every returned
measure can be sampled. tolerance is the flattening tolerance, and
bounds the measurement’s accuracy with it.