Enum frui::druid_shell::kurbo::PathSeg
[−]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
impl PathSeg
impl PathSeg
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));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
Get a subsegment of the curve for the given parameter range.
fn subdivide(&self) -> (Self, Self)
fn subdivide(&self) -> (Self, Self)
Subdivide into (roughly) halves.
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
Compute the signed area under the curve. Read more
impl ParamCurveExtrema for PathSeg
impl ParamCurveExtrema for PathSeg
fn extrema_ranges(&self) -> ArrayVec<[Range<f64>; 5]>
fn extrema_ranges(&self) -> ArrayVec<[Range<f64>; 5]>
Return parameter ranges, each of which is monotonic within the range.
fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
The smallest rectangle that encloses the curve in the range (0..1).
impl ParamCurveNearest for PathSeg
impl ParamCurveNearest for PathSeg
impl Shape for PathSeg
impl Shape for PathSeg
type PathElementsIter = PathSegIter
type PathElementsIter = PathSegIter
The iterator returned by the
path_elements method. Read morefn path_elements(&self, _tolerance: f64) -> PathSegIterⓘNotable traits for PathSegIterimpl Iterator for PathSegIter type Item = PathEl;
fn path_elements(&self, _tolerance: f64) -> PathSegIterⓘNotable traits for PathSegIterimpl Iterator for PathSegIter type Item = PathEl;
fn winding(&self, _pt: Point) -> i32
fn winding(&self, _pt: Point) -> i32
The winding number of a point. Read more
fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
The smallest rectangle that encloses the shape.
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter>ⓘNotable traits for Segments<I>impl<I> Iterator for Segments<I>where
I: Iterator<Item = PathEl>, type Item = PathSeg;
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter>ⓘNotable traits for Segments<I>impl<I> Iterator for Segments<I>where
I: Iterator<Item = PathEl>, type Item = PathSeg;
I: Iterator<Item = PathEl>, type Item = PathSeg;
fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
If the shape is a rounded rectangle, make it available.
fn as_path_slice(&self) -> Option<&[PathEl]>
fn as_path_slice(&self) -> Option<&[PathEl]>
If the shape is stored as a slice of path elements, make
that available. Read more
impl Copy for PathSeg
impl StructuralPartialEq for PathSeg
Auto Trait Implementations
impl Immutable for PathSeg
impl RefUnwindSafe for PathSeg
impl Send for PathSeg
impl Sync for PathSeg
impl Unpin for PathSeg
impl UnwindSafe for PathSeg
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more