pub struct Path { /* private fields */ }Expand description
A 2D geometric path.
Implementations§
Source§impl Path
impl Path
Sourcepub const fn set_fill_type(&mut self, fill_type: FillType)
pub const fn set_fill_type(&mut self, fill_type: FillType)
Set the fill type.
Sourcepub fn verb_count(&self) -> usize
pub fn verb_count(&self) -> usize
Get the number of verbs.
Sourcepub fn point_count(&self) -> usize
pub fn point_count(&self) -> usize
Get the number of points.
Sourcepub fn last_point(&self) -> Option<Point>
pub fn last_point(&self) -> Option<Point>
Get the last point in the path.
Sourcepub fn contour_count(&self) -> usize
pub fn contour_count(&self) -> usize
Get the number of contours in the path.
Sourcepub fn is_rect(&self) -> Option<Rect>
pub fn is_rect(&self) -> Option<Rect>
Check if the path represents a rectangle.
Ported from SkPathPriv::IsRectContour (single contour, allowPartial = false) with the trivial_rect fast-path: accepts the crate’s own
add_rect output (Move + 3 Lines + Close) and rejects non-rectangular
horizontal/vertical staircases by counting direction changes and
validating closure.
Sourcepub fn is_oval(&self) -> bool
pub fn is_oval(&self) -> bool
Returns true if this path is a simple oval (ellipse).
Verifies both verb structure (Move, 4 curves, Close) AND that the curve endpoints lie on the cardinal points of the bounding ellipse (left, right, top, bottom). This rejects 4-cubic paths that share the verb pattern but have arbitrary geometry.
Sourcepub fn convexity(&self) -> PathConvexity
pub fn convexity(&self) -> PathConvexity
Get the convexity of the path.
Ported from SkPathPriv::ComputeConvexity: per-contour and verb-aware.
Any second contour is Concave; convexity along a single contour is
determined by cross-product direction changes (including the closing
edges) via the Convexicator, with no fixed magnitude threshold.
Sourcepub fn direction(&self) -> Option<PathDirection>
pub fn direction(&self) -> Option<PathDirection>
Get the first direction of the path.
Ported from SkPathPriv::ComputeFirstDirection: loops over all contours
and keeps the cross product of the contour that contains the global
y-max (bottom-most point in y-down device space); cross > 0 => CW.
Sourcepub fn reverse(&mut self)
pub fn reverse(&mut self)
Reverse the path direction.
Ported from SkPathPriv::ReverseAddPath: walks contours back-to-front,
emitting Move first, points in reverse order with per-verb point-count
handling, and preserving one Close per originally-closed contour.
Sourcepub fn transformed(&self, matrix: &Matrix) -> Self
pub fn transformed(&self, matrix: &Matrix) -> Self
Create a transformed copy of the path.
Sourcepub fn contains(&self, point: Point) -> bool
pub fn contains(&self, point: Point) -> bool
Check if a point is inside the path (using the fill rule).
Ported from SkPathPriv::Contains: accumulates signed winding
(+1/-1 per crossing direction) via winding_line on each edge, treats
every contour as implicitly closed for hit-testing (like
SkPathEdgeIter), uses inclusive bounds for the early-out, and XORs the
result with the inverse-fill flag.
Sourcepub fn tight_bounds(&self) -> Rect
pub fn tight_bounds(&self) -> Rect
Returns the tight bounding rectangle of this path.
Unlike bounds(), this computes the bounds from the actual curve
extents, not the control-point bounding box. For cubic and quadratic
Bezier curves with control points outside the actual curve range,
tight_bounds() may be significantly smaller than bounds().
Conics fall back to control-polygon bounds (exact extrema for rational curves would require solving a quartic).
Trait Implementations§
Source§impl<'a> IntoIterator for &'a Path
impl<'a> IntoIterator for &'a 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