Struct tiny_skia_path::Path
source · pub struct Path {
pub(crate) verbs: Vec<PathVerb>,
pub(crate) points: Vec<Point>,
pub(crate) bounds: Rect,
}
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.
Fields§
§verbs: Vec<PathVerb>
§points: Vec<Point>
§bounds: Rect
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<Self>
pub fn transform(self, ts: Transform) -> Option<Self>
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.
Trait Implementations§
impl StructuralPartialEq for Path
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnwindSafe for Path
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)