Struct rasterize::Cubic[][src]

pub struct Cubic(pub [Point; 4]);

Cubic bezier curve

Polynimial form: (1 - t) ^ 3 * p0 + 3 * (1 - t) ^ 2 * t * p1 + 3 * (1 - t) * t ^ 2 * p2 + t ^ 3 * p3 Matrix from:

                ┌             ┐ ┌    ┐
┌             ┐ │  1  0  0  0 │ │ p0 │
│ 1 t t^2 t^3 │ │ -3  3  0  0 │ │ p1 │
└             ┘ │  3 -6  3  0 │ │ p2 │
                │ -1  3 -3  1 │ │ p3 │
                └             ┘ └    ┘

Implementations

impl Cubic[src]

pub fn new(
    p0: impl Into<Point>,
    p1: impl Into<Point>,
    p2: impl Into<Point>,
    p3: impl Into<Point>
) -> Self
[src]

Create new cubic bezier curve

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

Points defining cubic bezier curve

pub fn ends(&self) -> (Line, Line)[src]

Taget lines at the ends of cubic bezier curve

pub fn smooth(&self) -> Point[src]

Find smooth point used by SVG parser

Trait Implementations

impl Clone for Cubic[src]

impl Copy for Cubic[src]

impl Curve for Cubic[src]

fn flatness(&self) -> Scalar[src]

Flattness criteria for the cubic curve This function actually returns 16 * flatness^2

It is equal to f = max d(t) where d(t) = |c(t) - l(t)|, l(t) = (1 - t) * c0 + t * c3 for c(t) bezier3 curve with c{0..3} control points, in other words maximum distance from parametric line to bezier3 curve for the same parameter t. It is shown in the article that: f^2 <= 1/16 (max{u_x^2, v_x^2} + max{u_y^2, v_y^2}) where: u = 3 * b1 - 2 * b0 - b3 v = 3 * b2 - b0 - 2 * b3 f == 0 means completely flat so estimating upper bound is sufficient as spliting more than needed is not a problem for rendering.

Linear Approximation of Bezier Curve

fn split(&self) -> (Self, Self)[src]

Optimized version of split_at(0.5)

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

Offset cubic bezier curve with a list of cubic curves

Offset bezier curve using Tiller-Hanson method. In short, it will just offset line segment corresponding to control points, then find intersection of this lines and treat them as new control points.

impl Debug for Cubic[src]

impl Display for Cubic[src]

impl From<Cubic> for Segment[src]

impl From<Quad> for Cubic[src]

impl FromStr for Cubic[src]

type Err = SvgPathParserError

The associated error which can be returned from parsing.

impl PartialEq<Cubic> for Cubic[src]

impl StructuralPartialEq for Cubic[src]

Auto Trait Implementations

impl RefUnwindSafe for Cubic

impl Send for Cubic

impl Sync for Cubic

impl Unpin for Cubic

impl UnwindSafe for Cubic

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.