pub struct Path { /* private fields */ }Expand description
A path: a verb stream plus the points those verbs consume.
Implementations§
Source§impl Path
impl Path
pub fn builder() -> PathBuilder
Sourcepub fn as_rounded_rect(&self) -> Option<(Rect, f32)>
pub fn as_rounded_rect(&self) -> Option<(Rect, f32)>
The rounded rectangle this was built from, if it was built from one.
A radius of zero is a plain rectangle and is reported as such; None
means only that nothing recorded a shape, never that the outline is not
one.
pub fn verbs(&self) -> &[Verb]
pub fn points(&self) -> &[Vec2]
Sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Whether every point in this path is a real location.
A path carrying a NaN or an infinity is not a shape. It arrives when a caller’s own arithmetic has already gone wrong – a division by a zero extent, an inverted degenerate transform – and there is no picture it asks for, so the tessellator refuses one rather than inventing it.
Worth having as a question rather than a debug assertion because lyon asserts on a non-finite coordinate, and an assertion in a dependency takes the process down. A library given a bad number should decline to draw, not abort the application holding it.
Sourcepub fn is_within_tessellation_range(&self) -> bool
pub fn is_within_tessellation_range(&self) -> bool
Whether every coordinate is small enough to tessellate.
Finite is not the same as usable, and the gap between them is where the
tessellator’s cost stops being bounded. f32::MAX is finite; so is
1e15, and a path with three verbs at that magnitude strokes to
thirty-one million vertices – six hundred megabytes of position and
index from a cubic and a close. The fill route is safe from it because
this crate’s own flattener caps at MAX_SEGMENTS, but a stroke hands
its curves to lyon intact, deliberately and for the reason
Tessellator::stroke gives, and lyon subdivides by its own arithmetic
with no such cap. The output grows linearly in the coordinate, which
makes it a caller-controlled allocation with nothing at the top of it.
MAX_COORDINATE is where that stops, and the limit is the same one
two different arguments arrive at. A float past two to the twenty-fourth
has an interval above one between it and its neighbor, so a coordinate
there cannot name a pixel and no picture depends on it. And measured, a
curve at that magnitude strokes to about twenty thousand vertices,
which is a shape rather than an allocation.
pub fn fill_rule(&self) -> FillRule
pub fn is_empty(&self) -> bool
Sourcepub fn bounds(&self) -> Rect
pub fn bounds(&self) -> Rect
Bounds of the control points.
This is a bound, not a tight fit: a curve lies within the convex hull of its control points, so a curve that bends away from its handles reports a larger box than it occupies. That is the right trade for culling, where a conservative overestimate is safe and cheap while a tight fit costs a solve per curve.
Sourcepub fn segments(&self) -> impl Iterator<Item = (Verb, &[Vec2])>
pub fn segments(&self) -> impl Iterator<Item = (Verb, &[Vec2])>
Walk the path as (verb, points) pairs.
Sourcepub fn convexity(&self) -> Convexity
pub fn convexity(&self) -> Convexity
Whether the path is provably convex.
Answers Convexity::Concave for anything with more than one subpath,
or containing curves, rather than analyzing further. Curved paths are
classified after flattening, where the question is a polygon question.
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 UnsafeUnpin 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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more