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

Cubic bezier curve

Polynomial 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 │
                └             ┘ └    ┘

Tuple Fields

0: [Point; 4]

Implementations

Create new cubic bezier curve

Points defining cubic bezier curve

Tangent lines at the ends of cubic bezier curve

Find smooth point used by SVG parser

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Flatness 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 splitting more than needed is not a problem for rendering.

Linear Approximation of Bezier Curve

Optimized version of split_at(0.5)

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.

Apply affine transformation to the curve

Point at which curve starts

Point at which curve ends

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

Derivative with respect to t, deriv(t) = [curve'(t)_x, curve'(t)_y]

Split the curve at parameter value t

Create sub-curve specified starting at parameter value a and ending at value b

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

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

Find roots of the equation curve(t)_y = 0. Values of the parameter at which curve crosses y axis. Read more

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

Calculate length of the curve from t0 to t1

Convert curve to an iterator over line segments with desired flatness

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

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.