Struct rasterize::Line

source ·
pub struct Line(pub [Point; 2]);
Expand description

Line segment curve

Tuple Fields§

§0: [Point; 2]

Implementations§

source§

impl Line

source

pub fn new(p0: impl Into<Point>, p1: impl Into<Point>) -> Self

source

pub fn length(&self) -> Scalar

Length of the line

source

pub fn points(&self) -> [Point; 2]

Start and end points of the line

source

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

source

pub fn intersect(&self, other: Line) -> Option<(Scalar, Scalar)>

Find intersection of two lines

Returns pair of t parameters for this line and the other line. Found by solving self.at(t0) == other.at(t1). Actual intersection of line segments can be found by making sure that 0.0 <= t0 <= 1.0 && 0.0 <= t1 <= 1.0

source

pub fn intersect_point(&self, other: Line) -> Option<Point>

Find intersection point between two line segments

source

pub fn direction(&self) -> Point

Direction vector associated with the line segment

Trait Implementations§

source§

impl Clone for Line

source§

fn clone(&self) -> Line

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 Line

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 Line

source§

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

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

impl Display for Line

source§

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

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

impl From<Line> for Segment

source§

fn from(line: Line) -> Self

Converts to this type from the input type.
source§

impl FromStr for Line

§

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 Line

source§

fn eq(&self, other: &Line) -> 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 Line

source§

impl StructuralPartialEq for Line

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnwindSafe for Line

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.