#2d-graphics #2d #graphics #bezier #line-segment #geometry

no-std lyon_geom

2D quadratic and cubic bézier arcs and line segment math on top of euclid

34 releases (6 stable)

1.0.5 Dec 26, 2023
1.0.4 Dec 7, 2022
1.0.3 Nov 6, 2022
1.0.1 Jul 14, 2022
0.10.0 Mar 1, 2018

#458 in Graphics APIs

Download history 16942/week @ 2023-12-18 10463/week @ 2023-12-25 16652/week @ 2024-01-01 20898/week @ 2024-01-08 23978/week @ 2024-01-15 22860/week @ 2024-01-22 21166/week @ 2024-01-29 24816/week @ 2024-02-05 21770/week @ 2024-02-12 25650/week @ 2024-02-19 22693/week @ 2024-02-26 20880/week @ 2024-03-04 23865/week @ 2024-03-11 22176/week @ 2024-03-18 22500/week @ 2024-03-25 20498/week @ 2024-04-01

91,195 downloads per month
Used in 356 crates (16 directly)

MIT/Apache

265KB
6.5K SLoC

lyon::geom

2D geometric primitives on top of euclid.

crates.io documentation

lyon_geom can be used as a standalone crate or as part of lyon via the lyon::geom module.


lib.rs:

Simple 2D geometric primitives on top of euclid.

This crate is reexported in lyon.

Overview.

This crate implements some of the maths to work with:

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

Flattening

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

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.

Dependencies

~1.5MB
~28K SLoC