pub struct Path { /* private fields */ }
Expand description
A Bezier path.
Can be created via PathBuilder
.
Where PathBuilder
can be created from the Path
using clear
to reuse the allocation.
Path is immutable and uses compact storage, where segment types and numbers are stored
separately. Use can access path segments via Path::verbs
and Path::points
,
or via Path::segments
Guarantees
- Has a valid, precomputed bounds.
- All points are finite.
- Has at least two segments.
- Each contour starts with a MoveTo.
- No duplicated Move.
- No duplicated Close.
- Zero-length contours are allowed.
Implementations§
source§impl Path
impl Path
sourcepub fn dash(&self, dash: &StrokeDash, resolution_scale: f32) -> Option<Path>
pub fn dash(&self, dash: &StrokeDash, resolution_scale: f32) -> Option<Path>
Converts the current path into a dashed one.
resolution_scale
can be obtained via
compute_resolution_scale
.
Returns None
when more than 1_000_000 dashes had to be produced
or when the final path has an invalid bounding box.
source§impl Path
impl Path
sourcepub fn bounds(&self) -> Rect
pub fn bounds(&self) -> Rect
Returns the bounds of the path’s points.
The value is already calculated.
sourcepub fn compute_tight_bounds(&self) -> Option<Rect>
pub fn compute_tight_bounds(&self) -> Option<Rect>
Calculates path’s tight bounds.
This operation can be expensive.
sourcepub fn transform(self, ts: Transform) -> Option<Path>
pub fn transform(self, ts: Transform) -> Option<Path>
Returns a transformed in-place path.
Some points may become NaN/inf therefore this method can fail.
sourcepub fn segments(&self) -> PathSegmentsIter<'_> ⓘ
pub fn segments(&self) -> PathSegmentsIter<'_> ⓘ
Returns an iterator over path’s segments.
sourcepub fn clear(self) -> PathBuilder
pub fn clear(self) -> PathBuilder
Clears the path and returns a PathBuilder
that will reuse an allocated memory.
source§impl Path
impl Path
sourcepub fn stroke(&self, stroke: &Stroke, resolution_scale: f32) -> Option<Path>
pub fn stroke(&self, stroke: &Stroke, resolution_scale: f32) -> Option<Path>
Returns a stoked path.
resolution_scale
can be obtained via
compute_resolution_scale
.
If you plan stroking multiple paths, you can try using PathStroker
which will preserve temporary allocations required during stroking.
This might improve performance a bit.