#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

#580 in Graphics APIs

Download history 29220/week @ 2024-07-28 28768/week @ 2024-08-04 36814/week @ 2024-08-11 28821/week @ 2024-08-18 30665/week @ 2024-08-25 32744/week @ 2024-09-01 31434/week @ 2024-09-08 30444/week @ 2024-09-15 33262/week @ 2024-09-22 34351/week @ 2024-09-29 32162/week @ 2024-10-06 35919/week @ 2024-10-13 38798/week @ 2024-10-20 39839/week @ 2024-10-27 42849/week @ 2024-11-03 25440/week @ 2024-11-10

148,989 downloads per month
Used in 396 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