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
impl PathSeg
sourcepub 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.
sourcepub fn reverse(&self) -> PathSeg
pub fn reverse(&self) -> PathSeg
Returns a new PathSeg
describing the same path as self
, but with
the points reversed.
sourcepub 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§
source§impl<'de> Deserialize<'de> for PathSeg
impl<'de> Deserialize<'de> for PathSeg
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl JsonSchema for PathSeg
impl JsonSchema for PathSeg
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl Mul<PathSeg> for TranslateScale
impl Mul<PathSeg> for TranslateScale
source§impl ParamCurve for PathSeg
impl ParamCurve for PathSeg
source§impl ParamCurveArclen for PathSeg
impl ParamCurveArclen for PathSeg
source§impl ParamCurveArea for PathSeg
impl ParamCurveArea for PathSeg
source§fn signed_area(&self) -> f64
fn signed_area(&self) -> f64
source§impl ParamCurveExtrema for PathSeg
impl ParamCurveExtrema for PathSeg
source§fn extrema_ranges(&self) -> ArrayVec<Range<f64>, { _ }>
fn extrema_ranges(&self) -> ArrayVec<Range<f64>, { _ }>
source§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
source§impl ParamCurveNearest for PathSeg
impl ParamCurveNearest for PathSeg
source§impl Shape for PathSeg
impl Shape for PathSeg
source§fn area(&self) -> f64
fn area(&self) -> f64
The area under the curve.
We could just return 0
, but this seems more useful.
source§type PathElementsIter<'iter> = PathSegIter
type PathElementsIter<'iter> = PathSegIter
path_elements
method.source§fn path_elements(&self, _tolerance: f64) -> PathSegIter ⓘ
fn path_elements(&self, _tolerance: f64) -> PathSegIter ⓘ
source§fn bounding_box(&self) -> Rect
fn bounding_box(&self) -> Rect
source§fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
fn into_path(self, tolerance: f64) -> BezPathwhere
Self: Sized,
source§fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
fn path_segments(&self, tolerance: f64) -> Segments<Self::PathElementsIter<'_>> ⓘ
source§fn as_rounded_rect(&self) -> Option<RoundedRect>
fn as_rounded_rect(&self) -> Option<RoundedRect>
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 UnwindSafe for PathSeg
Blanket Implementations§
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)