pub struct Path2D { /* private fields */ }Expand description
A device-space path: a list of subpaths of absolute segments.
Implementations§
Source§impl Path2D
impl Path2D
Sourcepub fn commands(&self) -> &[PathCommand]
pub fn commands(&self) -> &[PathCommand]
The commands, in order.
Sourcepub fn push(&mut self, cmd: PathCommand) -> &mut Self
pub fn push(&mut self, cmd: PathCommand) -> &mut Self
Append a command verbatim.
Sourcepub fn bbox(&self) -> Option<Rect>
pub fn bbox(&self) -> Option<Rect>
The exact bounding box, None for an empty path.
Curves contribute their true extrema, the same way font-model’s
outline bounding boxes do — a rasteriser that trusted a control hull
would clip antialiased edges.
Sourcepub fn transformed(&self, m: &Affine2D) -> Path2D
pub fn transformed(&self, m: &Affine2D) -> Path2D
Apply an affine transform to every point, curves included.
The result is a new path; the original is untouched. Control points transform exactly like endpoints, which is what makes a transformed curve the same curve as the untransformed one.
Sourcepub fn translated(&self, dx: f32, dy: f32) -> Path2D
pub fn translated(&self, dx: f32, dy: f32) -> Path2D
Translate the whole path.
Sourcepub fn subpath_count(&self) -> usize
pub fn subpath_count(&self) -> usize
The number of subpaths (each MoveTo starts one).
Sourcepub fn flatten(&self, tolerance: f32) -> Vec<Vec<(f32, f32)>>
pub fn flatten(&self, tolerance: f32) -> Vec<Vec<(f32, f32)>>
Flatten to polylines: Vec<Vec<(f32, f32)>>, one per subpath, each
starting at its first point and (for a closed subpath) ending back
there.
tolerance is the maximum distance a flattened point may sit from the
curve. Smaller is more accurate and slower; 0.0 selects a sane default
derived from the path’s own extent.
Sourcepub fn polygon_area(&self) -> f32
pub fn polygon_area(&self) -> f32
The polygonal area of the flattened path, for a coverage sanity check.
This is the area of the flattened polygon, so it is within the
flattening tolerance of the true curve area, and it is the number
fill_path’s coverage should sum to.
An edge with a non-finite endpoint is skipped rather than summed, so hostile geometry gives a finite answer — the area of whatever part of the path is still well-defined — instead of NaN.