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

no-std lyon_geom

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

35 releases (7 stable)

1.0.6 Oct 23, 2024
1.0.5 Dec 26, 2023
1.0.4 Dec 7, 2022
1.0.3 Nov 6, 2022
0.10.0 Mar 1, 2018

#582 in Graphics APIs

Download history 28705/week @ 2024-08-21 30769/week @ 2024-08-28 34166/week @ 2024-09-04 30072/week @ 2024-09-11 32260/week @ 2024-09-18 31998/week @ 2024-09-25 36220/week @ 2024-10-02 31425/week @ 2024-10-09 37612/week @ 2024-10-16 39414/week @ 2024-10-23 41786/week @ 2024-10-30 36184/week @ 2024-11-06 28057/week @ 2024-11-13 30389/week @ 2024-11-20 29518/week @ 2024-11-27 23351/week @ 2024-12-04

116,434 downloads per month
Used in 397 crates (17 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
~27K SLoC