Enum piet_common::kurbo::PathSeg[]

pub enum PathSeg {
    Line(Line),
    Quad(QuadBez),
    Cubic(CubicBez),
}

A segment of a Bézier path.

Variants

Line(Line)

A line segment.

Quad(QuadBez)

A quadratic bezier segment.

Cubic(CubicBez)

A cubic bezier segment.

Implementations

impl PathSeg

pub fn reverse(&self) -> PathSeg

Returns a new PathSeg describing the same path as self, but with the points reversed.

pub fn to_cubic(&self) -> CubicBez

Convert this segment to a cubic bezier.

pub fn intersect_line(&self, line: Line) -> ArrayVec<[LineIntersection; 3]>

Compute intersections against a line.

Returns a vector of the intersections. For each intersection, the t value of the segment and line are given.

Note: This test is designed to be inclusive of points near the endpoints of the segment. This is so that testing a line against multiple contiguous segments of a path will be guaranteed to catch at least one of them. In such cases, use higher level logic to coalesce the hits (the t value may be slightly outside the range of 0..1).

Examples

let seg = PathSeg::Line(Line::new((0.0, 0.0), (2.0, 0.0)));
let line = Line::new((1.0, 2.0), (1.0, -2.0));
let intersection = seg.intersect_line(line);
assert_eq!(intersection.len(), 1);
let intersection = intersection[0];
assert_eq!(intersection.segment_t, 0.5);
assert_eq!(intersection.line_t, 0.5);

let point = seg.eval(intersection.segment_t);
assert_eq!(point, Point::new(1.0, 0.0));

pub fn is_finite(&self) -> bool

Is this Bezier path finite?

pub fn is_nan(&self) -> bool

Is this Bezier path NaN?

Trait Implementations

impl Clone for PathSeg

impl Copy for PathSeg

impl Debug for PathSeg

impl From<CubicBez> for PathSeg

impl From<Line> for PathSeg

impl From<QuadBez> for PathSeg

impl Mul<PathSeg> for TranslateScale

type Output = PathSeg

The resulting type after applying the * operator.

impl Mul<PathSeg> for Affine

type Output = PathSeg

The resulting type after applying the * operator.

impl ParamCurve for PathSeg

impl ParamCurveArclen for PathSeg

impl ParamCurveArea for PathSeg

impl ParamCurveExtrema for PathSeg

impl ParamCurveNearest for PathSeg

impl PartialEq<PathSeg> for PathSeg

impl Shape for PathSeg

type PathElementsIter = PathSegIter

The iterator returned by the path_elements method. Read more

pub fn area(&self) -> f64

The area under the curve.

We could just return 0, but this seems more useful.

impl StructuralPartialEq for PathSeg

Auto Trait Implementations

impl RefUnwindSafe for PathSeg

impl Send for PathSeg

impl Sync for PathSeg

impl Unpin for PathSeg

impl UnwindSafe for PathSeg

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.