Skip to main content

PathSeg

Enum PathSeg 

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

A segment of a Bézier path.

Variants§

§

Line(Line)

A line segment.

§

Quad(QuadBez)

A quadratic Bézier segment.

§

Cubic(CubicBez)

A cubic Bézier segment.

Implementations§

Source§

impl PathSeg

Source

pub fn as_path_el(&self) -> PathEl

Get the PathEl that is equivalent to discarding the segment start point.

Source

pub fn reverse(&self) -> PathSeg

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

Source

pub fn to_cubic(&self) -> CubicBez

Convert this segment to a cubic Bézier.

Source

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));
Source

pub fn is_finite(&self) -> bool

Is this Bézier path finite?

Source

pub fn is_nan(&self) -> bool

Is this Bézier path NaN?

Source

pub fn min_dist(&self, other: PathSeg, accuracy: f64) -> MinDistance

Minimum distance between two PathSegs.

Returns a tuple of the distance, the path time t1 of the closest point on the first PathSeg, and the path time t2 of the closest point on the second PathSeg.

Trait Implementations§

Source§

impl Clone for PathSeg

Source§

fn clone(&self) -> PathSeg

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PathSeg

Source§

impl Debug for PathSeg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<CubicBez> for PathSeg

Source§

fn from(cubic_bez: CubicBez) -> PathSeg

Converts to this type from the input type.
Source§

impl From<Line> for PathSeg

Source§

fn from(line: Line) -> PathSeg

Converts to this type from the input type.
Source§

impl From<QuadBez> for PathSeg

Source§

fn from(quad_bez: QuadBez) -> PathSeg

Converts to this type from the input type.
Source§

impl Mul<PathSeg> for Affine

Source§

type Output = PathSeg

The resulting type after applying the * operator.
Source§

fn mul(self, other: PathSeg) -> PathSeg

Performs the * operation. Read more
Source§

impl Mul<PathSeg> for TranslateScale

Source§

type Output = PathSeg

The resulting type after applying the * operator.
Source§

fn mul(self, other: PathSeg) -> PathSeg

Performs the * operation. Read more
Source§

impl ParamCurve for PathSeg

Source§

fn eval(&self, t: f64) -> Point

Evaluate the curve at parameter t. Read more
Source§

fn subsegment(&self, range: Range<f64>) -> PathSeg

Get a subsegment of the curve for the given parameter range.
Source§

fn start(&self) -> Point

The start point.
Source§

fn end(&self) -> Point

The end point.
Source§

fn subdivide(&self) -> (Self, Self)

Subdivide into (roughly) halves.
Source§

impl ParamCurveArclen for PathSeg

Source§

fn arclen(&self, accuracy: f64) -> f64

The arc length of the curve. Read more
Source§

fn inv_arclen(&self, arclen: f64, accuracy: f64) -> f64

Solve for the parameter that has the given arc length from the start. Read more
Source§

impl ParamCurveArea for PathSeg

Source§

fn signed_area(&self) -> f64

Compute the signed area under the curve. Read more
Source§

impl ParamCurveExtrema for PathSeg

Source§

fn extrema( &self, ) -> ArrayVec<f64, kurbo::::bezpath::{impl#20}::extrema::{constant#0}>

Compute the extrema of the curve. Read more
Source§

fn extrema_ranges( &self, ) -> ArrayVec<Range<f64>, kurbo::::param_curve::ParamCurveExtrema::extrema_ranges::{constant#0}>

Return parameter ranges, each of which is monotonic within the range.
Source§

fn bounding_box(&self) -> Rect

The smallest rectangle that encloses the curve in the range (0..1).
Source§

impl ParamCurveNearest for PathSeg

Source§

fn nearest(&self, p: Point, accuracy: f64) -> Nearest

Find the position on the curve that is nearest to the given point. Read more
Source§

impl PartialEq for PathSeg

Source§

fn eq(&self, other: &PathSeg) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Shape for PathSeg

Source§

fn area(&self) -> f64

The area under the curve.

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

Source§

type PathElementsIter<'iter> = PathSegIter

The iterator returned by the path_elements method.
Source§

fn path_elements(&self, _tolerance: f64) -> PathSegIter ⓘ

Returns an iterator over this shape expressed as PathEls; that is, as Bézier path elements. Read more
Source§

fn perimeter(&self, accuracy: f64) -> f64

Total length of perimeter.
Source§

fn winding(&self, _pt: Point) -> i32

The winding number of a point. Read more
Source§

fn bounding_box(&self) -> Rect

The smallest rectangle that encloses the shape.
Source§

fn as_line(&self) -> Option<Line>

If the shape is a line, make it available.
Source§

fn to_path(&self, tolerance: f64) -> BezPath

Convert to a Bézier path. Read more
Source§

fn into_path(self, tolerance: f64) -> BezPath
where Self: Sized,

Convert into a Bézier path. Read more
Source§

fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ

Returns an iterator over this shape expressed as Bézier path segments (PathSegs). Read more
Source§

fn contains(&self, pt: Point) -> bool

Returns true if the Point is inside this shape. Read more
Source§

fn as_rect(&self) -> Option<Rect>

If the shape is a rectangle, make it available.
Source§

fn as_rounded_rect(&self) -> Option<RoundedRect>

If the shape is a rounded rectangle, make it available.
Source§

fn as_circle(&self) -> Option<Circle>

If the shape is a circle, make it available.
Source§

fn as_path_slice(&self) -> Option<&[PathEl]>

If the shape is stored as a slice of path elements, make that available. Read more
Source§

impl StructuralPartialEq for PathSeg

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more