Enum PathSeg
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§
§impl PathSeg
impl PathSeg
pub fn as_path_el(&self) -> PathEl
pub fn as_path_el(&self) -> PathEl
Get the PathEl that is equivalent to discarding the segment start point.
pub fn reverse(&self) -> PathSeg
pub fn reverse(&self) -> PathSeg
Returns a new PathSeg describing the same path as self, but with
the points reversed.
pub fn intersect_line(&self, line: Line) -> ArrayVec<LineIntersection, 3>
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 min_dist(&self, other: PathSeg, accuracy: f64) -> MinDistance
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§
§impl Mul<PathSeg> for TranslateScale
impl Mul<PathSeg> for TranslateScale
§impl ParamCurve for PathSeg
impl ParamCurve for PathSeg
§fn subsegment(&self, range: Range<f64>) -> PathSeg
fn subsegment(&self, range: Range<f64>) -> PathSeg
§impl ParamCurveArclen for PathSeg
impl ParamCurveArclen for PathSeg
§impl ParamCurveArea for PathSeg
impl ParamCurveArea for PathSeg
§fn signed_area(&self) -> f64
fn signed_area(&self) -> f64
§impl ParamCurveExtrema for PathSeg
impl ParamCurveExtrema for PathSeg
§fn extrema(
&self,
) -> ArrayVec<f64, kurbo::::bezpath::{impl#20}::extrema::{constant#0}>
fn extrema( &self, ) -> ArrayVec<f64, kurbo::::bezpath::{impl#20}::extrema::{constant#0}>
§fn extrema_ranges(
&self,
) -> ArrayVec<Range<f64>, kurbo::::param_curve::ParamCurveExtrema::extrema_ranges::{constant#0}>
fn extrema_ranges( &self, ) -> ArrayVec<Range<f64>, kurbo::::param_curve::ParamCurveExtrema::extrema_ranges::{constant#0}>
§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
§impl ParamCurveNearest for PathSeg
impl ParamCurveNearest for PathSeg
§impl Shape for PathSeg
impl Shape for PathSeg
§type PathElementsIter<'iter> = PathSegIter
type PathElementsIter<'iter> = PathSegIter
path_elements method.§fn path_elements(&self, _tolerance: f64) -> PathSegIter ⓘ
fn path_elements(&self, _tolerance: f64) -> PathSegIter ⓘ
§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
§fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
§fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
§fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
§fn as_path_slice(&self) -> Option<&[PathEl]>
fn as_path_slice(&self) -> Option<&[PathEl]>
impl Copy for PathSeg
impl StructuralPartialEq for PathSeg
Auto Trait Implementations§
impl Freeze for PathSeg
impl RefUnwindSafe for PathSeg
impl Send for PathSeg
impl Sync for PathSeg
impl Unpin for PathSeg
impl UnsafeUnpin for PathSeg
impl UnwindSafe for PathSeg
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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