[−]Enum druid::kurbo::PathSeg
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));
Trait Implementations
impl Clone for PathSeg
pub fn clone(&self) -> PathSeg
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for PathSeg
impl Data for PathSeg
[src]
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.
pub fn mul(self, other: PathSeg) -> PathSeg
impl Mul<PathSeg> for Affine
type Output = PathSeg
The resulting type after applying the *
operator.
pub fn mul(self, other: PathSeg) -> PathSeg
impl ParamCurve for PathSeg
pub fn eval(&self, t: f64) -> Point
pub fn subsegment(&self, range: Range<f64>) -> PathSeg
pub fn subdivide(&self) -> (Self, Self)
pub fn start(&self) -> Point
pub fn end(&self) -> Point
impl ParamCurveArclen for PathSeg
pub fn arclen(&self, accuracy: f64) -> f64
pub fn inv_arclen(&self, arclen: f64, accuracy: f64) -> f64
impl ParamCurveArea for PathSeg
pub fn signed_area(&self) -> f64
impl ParamCurveExtrema for PathSeg
pub fn extrema(&self) -> ArrayVec<[f64; 4]>
pub fn extrema_ranges(&self) -> ArrayVec<[Range<f64>; 5]>
pub fn bounding_box(&self) -> Rect
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 path_elements(&self, _tolerance: f64) -> PathSegIterⓘNotable traits for PathSegIter
impl Iterator for PathSegIter type Item = PathEl;
Notable traits for PathSegIter
impl Iterator for PathSegIter type Item = PathEl;
pub fn area(&self) -> f64
The area under the curve.
We could just return 0, but this seems more useful.
pub fn perimeter(&self, accuracy: f64) -> f64
pub fn winding(&self, _pt: Point) -> i32
pub fn bounding_box(&self) -> Rect
pub fn as_line(&self) -> Option<Line>
pub fn to_path(&self, tolerance: f64) -> BezPath
pub fn into_path(self, tolerance: f64) -> BezPath
pub fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter>ⓘ
pub fn contains(&self, pt: Point) -> bool
pub fn as_rect(&self) -> Option<Rect>
pub fn as_rounded_rect(&self) -> Option<RoundedRect>
pub fn as_circle(&self) -> Option<Circle>
pub fn as_path_slice(&self) -> Option<&[PathEl]>
impl StructuralPartialEq for PathSeg
Auto Trait Implementations
impl RefUnwindSafe for PathSeg
[src]
impl Send for PathSeg
[src]
impl Sync for PathSeg
[src]
impl Unpin for PathSeg
[src]
impl UnwindSafe for PathSeg
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AnyEq for T where
T: PartialEq<T> + Any,
[src]
T: PartialEq<T> + Any,
pub fn equals(&self, other: &(dyn Any + 'static)) -> bool
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,