Expand description

Simple 2D geometric primitives on top of euclid.

This crate is reexported in lyon.


This crate implements some of the maths to work with:

  • lines and line segments,
  • quadratic and cubic bézier curves,
  • elliptic arcs,
  • triangles.


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.


pub use arrayvec;
pub use euclid;



An angle in radians. An angle in radians

An elliptic arc curve segment.

Flag parameters for arcs as described by the SVG specification.

A 2d curve segment defined by four points: the beginning of the segment, two control points and the end of the segment.

An infinite line defined by a point and a vector.

A line defined by the equation a * x + b * y + c = 0; a * a + b * b = 1.

A linear segment.

A x and y monotonic curve segment, for example Monotonic<QuadraticBezierSegment>.

A 2d curve segment defined by three points: the beginning of the segment, a control point and the end of the segment.

An elliptic arc curve segment using the SVG’s end-point notation.

A 2D triangle defined by three points a, b and c.


Either a cubic, quadratic or linear bézier segment.


Common APIs to segment types.


Shorthand for Point::new(x, y).

Shorthand for Rect::new(Point::new(x, y), Size::new(w, h)).

Shorthand for Size::new(x, y).

Shorthand for Vector::new(x, y).

Type Definitions

Alias for euclid::default::Box2D

Alias for euclid::default::Point2D.

Alias for euclid::default::Rect

Alias for euclid::default::Rotation2D

Alias for euclid::default::Scale

Alias for euclid::default::Size2D.

Alias for euclid::default::Transform2D

Alias for euclid::default::Translation2D

Alias for euclid::default::Vector2D.