pub enum Segment {
Line(Line),
Quad(Quad),
Cubic(Cubic),
}
Variants§
Implementations§
source§impl Segment
impl Segment
pub fn ends(&self) -> (Line, Line)
sourcepub fn intersect(
self,
other: impl Into<Segment>,
tolerance: Scalar
) -> Vec<Point>
pub fn intersect( self, other: impl Into<Segment>, tolerance: Scalar ) -> Vec<Point>
Find intersection between two segments
This might not be the fastest method possible but works for any two curves. Divide curves as long as there is intersection between bounding boxes, if the intersection is smaller than tolerance we can treat it as an intersection point.
NOTE: This produces duplicate results which are close to each other. Why?
sourcepub fn to_cubic(&self) -> Option<Cubic>
pub fn to_cubic(&self) -> Option<Cubic>
Convert to cubic if it is a cubic variant of the segment
sourcepub fn line_join(
self,
other: Segment,
stroke_style: StrokeStyle
) -> impl Iterator<Item = Self>
pub fn line_join( self, other: Segment, stroke_style: StrokeStyle ) -> impl Iterator<Item = Self>
Produce iterator over segments that join to segments with the specified method.
sourcepub fn line_cap(
self,
other: Segment,
stroke_style: StrokeStyle
) -> impl Iterator<Item = Self>
pub fn line_cap( self, other: Segment, stroke_style: StrokeStyle ) -> impl Iterator<Item = Self>
Produce and iterator over segments that adds caps between two segments
Trait Implementations§
source§impl Curve for Segment
impl Curve for Segment
source§fn flatness(&self) -> Scalar
fn flatness(&self) -> Scalar
Correspond to maximum deviation of the curve from the straight line
f = max |curve(t) - line(curve_start, curve_end)(t)|
. This function
actually returns 16.0 * f^2
to avoid unneeded division and square root.source§fn deriv(&self) -> Segment
fn deriv(&self) -> Segment
Derivative with respect to t,
deriv(t) = [curve'(t)_x, curve'(t)_y]
source§fn split_at(&self, t: Scalar) -> (Self, Self)
fn split_at(&self, t: Scalar) -> (Self, Self)
Split the curve at parameter value
t
source§fn cut(&self, a: Scalar, b: Scalar) -> Self
fn cut(&self, a: Scalar, b: Scalar) -> Self
Create sub-curve specified starting at parameter value
a
and ending at value b
source§fn bbox(&self, init: Option<BBox>) -> BBox
fn bbox(&self, init: Option<BBox>) -> BBox
Extend provided
init
bounding box with the bounding box of the curvesource§fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
Offset the curve by distance
dist
, result is inserted into out
containersource§fn reverse(&self) -> Self
fn reverse(&self) -> Self
Identical curve but directed from end to start, instead of start to end.
source§fn roots(&self) -> CurveRoots
fn roots(&self) -> CurveRoots
Find roots of the equation
curve(t)_y = 0
. Values of the parameter at which curve
crosses y axis.source§fn extremities(&self) -> CurveExtremities
fn extremities(&self) -> CurveExtremities
Find all extremities of the curve
curve'(t)_x = 0 || curve'(t)_y = 0
source§fn length(&self, t0: Scalar, t1: Scalar) -> Scalar
fn length(&self, t0: Scalar, t1: Scalar) -> Scalar
Calculate length of the curve from
t0
to t1
source§fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
Convert curve to an iterator over line segments with desired flatness
source§fn split(&self) -> (Self, Self)
fn split(&self) -> (Self, Self)
Optimized version of
Curve::split_at(0.5)
source§impl PartialEq for Segment
impl PartialEq for Segment
impl Copy for Segment
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnwindSafe for Segment
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
Mutably borrows from an owned value. Read more