Enum kurbo::PathSeg[][src]

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[src]

pub fn reverse(&self) -> PathSeg[src]

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

pub fn to_cubic(&self) -> CubicBez[src]

Convert this segment to a cubic bezier.

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

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[src]

Is this Bezier path finite?

pub fn is_nan(&self) -> bool[src]

Is this Bezier path NaN?

Trait Implementations

impl Clone for PathSeg[src]

impl Copy for PathSeg[src]

impl Debug for PathSeg[src]

impl<'de> Deserialize<'de> for PathSeg[src]

impl From<CubicBez> for PathSeg[src]

impl From<Line> for PathSeg[src]

impl From<QuadBez> for PathSeg[src]

impl Mul<PathSeg> for Affine[src]

type Output = PathSeg

The resulting type after applying the * operator.

impl Mul<PathSeg> for TranslateScale[src]

type Output = PathSeg

The resulting type after applying the * operator.

impl ParamCurve for PathSeg[src]

impl ParamCurveArclen for PathSeg[src]

impl ParamCurveArea for PathSeg[src]

impl ParamCurveExtrema for PathSeg[src]

impl ParamCurveNearest for PathSeg[src]

impl PartialEq<PathSeg> for PathSeg[src]

impl Serialize for PathSeg[src]

impl Shape for PathSeg[src]

type PathElementsIter = PathSegIter

The iterator returned by the path_elements method. Read more

fn area(&self) -> f64[src]

The area under the curve.

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

impl StructuralPartialEq for PathSeg[src]

Auto Trait Implementations

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

impl<T, U> Into<U> for T where
    U: From<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.