Crate lyon_bezier [] [src]

Bézier curve related maths and tools.

This crate implements simple 2d quadratic and cubic bézier math and an efficient flattening algorithm on top of eulcid.

Flattening

Flattening is the action of approximating a curve with a succession of line segments.

The flattening algorithm implemented in this crate is based on the paper Fast, Precise Flattening of Cubic Bézier Segment Offset Curves. It tends to produce a better approximations than the usual recursive subdivision approach (or in other words, it generates less segments for a given tolerance threshold).

The tolerance threshold taken as input by the flattening algorithms corresponds to the maximum distance between the curve and its linear approximation. The smaller the tolerance is, the more precise the approximation and the more segments are generated. This value is typically chosen in function of the zoom level.

The figure above shows a close up on a curve (the dotted line) and its linear approximation (the black segments). The tolerance threshold is represented by the light green area and the orange arrow.

Reexports

pub use quadratic_bezier::QuadraticBezierSegment;
pub use cubic_bezier::CubicBezierSegment;

Modules

cubic_bezier
quadratic_bezier
utils

Structs

Arc
ArcFlags

Flag parameters for arcs as described by the SVG specification.

Line
LineSegment
SvgArc
Triangle

Functions

cubic_to_quadratic

Approximate a cubic bezier segment with a sequence of quadratic bezier segments.

Type Definitions

Point

Alias for euclid::Point2D<f32>.

Radians
Rect

Alias for euclid::Rect<f32>

Size

Alias for euclid::Size2D<f32>.

Transform2D

Alias for euclid::Transform2D<f32>

UpToTwo
Vec2

Alias for euclid::Point2D<f32>.