Trait rasterize::Curve[][src]

pub trait Curve: Into<Segment> {
Show 17 methods fn flatness(&self) -> Scalar;
fn transform(&self, tr: Transform) -> Self;
fn start(&self) -> Point;
fn end(&self) -> Point;
fn at(&self, t: Scalar) -> Point;
fn split_at(&self, t: Scalar) -> (Self, Self);
fn cut(&self, a: Scalar, b: Scalar) -> Self;
fn bbox(&self, init: Option<BBox>) -> BBox;
fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>);
fn deriv(&self) -> Segment;
fn reverse(&self) -> Self;
fn roots(&self) -> CurveRoots;
fn extremities(&self) -> CurveExtremities;
fn length(&self, t0: Scalar, t1: Scalar) -> Scalar; fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter
Notable traits for CurveFlattenIter
impl Iterator for CurveFlattenIter type Item = Line;
{ ... }
fn split(&self) -> (Self, Self) { ... }
fn from_length(&self, l: Scalar, error: Option<Scalar>) -> Scalar { ... }
}
Expand description

Set of operations common to all bezier curves.

Required methods

Correspond to maximum diviation 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.

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)

Split the curve at prameter value t

Create subcurve specified starting at parameter value a and ending at value b

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

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

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

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.

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

Calculate length of the curve from t0 to t1

Provided methods

Convert curve to an iterator over line segments with desired flatness

Optimized version of Curve::split_at(0.5)

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

This method is not particulary fast, parmeter value is found by solving f(t) = self.length(0.0, t) - l == 0 using Newton’s method with fallback to bisection if next iteration will produce out of bound value.

Reference: https://www.geometrictools.com/Documentation/MovingAlongCurveSpecifiedSpeed.pdf

Implementors