Enum rasterize::Segment

source ·
pub enum Segment {
    Line(Line),
    Quad(Quad),
    Cubic(Cubic),
}
Expand description

Segment is an enum of either Line, Quad or Cubic

Variants§

§

Line(Line)

§

Quad(Quad)

§

Cubic(Cubic)

Implementations§

source§

impl Segment

source

pub fn ends(&self) -> (Line, Line)

source

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?

source

pub fn to_line(&self) -> Option<Line>

Convert to line if it is a line variant of the segment

source

pub fn to_quad(&self) -> Option<Quad>

Convert to quad if it is a quad variant of the segment

source

pub fn to_cubic(&self) -> Option<Cubic>

Convert to cubic if it is a cubic variant of the segment

source

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.

source

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 Clone for Segment

source§

fn clone(&self) -> Segment

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Curve for Segment

source§

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 transform(&self, tr: Transform) -> Self

Apply affine transformation to the curve
source§

fn start(&self) -> Point

Point at which curve starts
source§

fn end(&self) -> Point

Point at which curve ends
source§

fn at(&self, t: Scalar) -> Point

Evaluate curve at parameter value t in (0.0..=1.0)
source§

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)

Split the curve at parameter value t
source§

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

Extend provided init bounding box with the bounding box of the curve
source§

fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)

Offset the curve by distance dist, result is inserted into out container
source§

fn reverse(&self) -> Self

Identical curve but directed from end to start, instead of start to end.
source§

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

Find all extremities of the curve curve'(t)_x = 0 || curve'(t)_y = 0
source§

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

Convert curve to an iterator over line segments with desired flatness
source§

fn split(&self) -> (Self, Self)

Optimized version of Curve::split_at(0.5)
source§

fn param_at_length(&self, l: Scalar, error: Option<Scalar>) -> Scalar

Find value of parameter t given desired l length of the segment Read more
source§

impl Debug for Segment

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Segment

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Cubic> for Segment

source§

fn from(cubic: Cubic) -> Self

Converts to this type from the input type.
source§

impl From<Line> for Segment

source§

fn from(line: Line) -> Self

Converts to this type from the input type.
source§

impl From<Quad> for Segment

source§

fn from(quad: Quad) -> Self

Converts to this type from the input type.
source§

impl FromStr for Segment

§

type Err = SvgParserError

The associated error which can be returned from parsing.
source§

fn from_str(text: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq for Segment

source§

fn eq(&self, other: &Segment) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Segment

source§

impl StructuralPartialEq for Segment

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.