Enum kurbo::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 bezier segment.

§

Cubic(CubicBez)

A cubic bezier 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 bezier.

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 Bezier path finite?

source

pub fn is_nan(&self) -> bool

Is this Bezier 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 copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for PathSeg

source§

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

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

impl<'de> Deserialize<'de> for PathSeg

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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 JsonSchema for PathSeg

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
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 subdivide(&self) -> (Self, Self)

Subdivide into (roughly) halves.
source§

fn start(&self) -> Point

The start point.
source§

fn end(&self) -> Point

The end point.
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, MAX_EXTREMA>

Compute the extrema of the curve. Read more
source§

fn extrema_ranges(&self) -> ArrayVec<Range<f64>, { _ }>

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for PathSeg

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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 Copy for PathSeg

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<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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