#2d-graphics #computational-geometry #curve #bezier #geometry #graphics #vector-graphics

bezier-rs

Computational geometry algorithms for Bézier segments and shapes useful in the context of 2D graphics

4 releases (breaking)

0.4.0 Jan 28, 2024
0.3.0 Jan 7, 2024
0.2.0 Mar 28, 2023
0.1.0 Dec 18, 2022

#127 in Math

Download history 48/week @ 2024-01-02 23/week @ 2024-01-09 1285/week @ 2024-01-16 350/week @ 2024-01-23 358/week @ 2024-01-30 331/week @ 2024-02-06 1115/week @ 2024-02-13 405/week @ 2024-02-20 340/week @ 2024-02-27 84/week @ 2024-03-05 207/week @ 2024-03-12 536/week @ 2024-03-19 233/week @ 2024-03-26 234/week @ 2024-04-02 305/week @ 2024-04-09 133/week @ 2024-04-16

1,061 downloads per month
Used in fj-text

MIT/Apache

320KB
5.5K SLoC

crates.iodocs.rsrepo

Bezier-rs

Computational geometry algorithms for Bézier segments and shapes useful in the context of 2D graphics.

Play with the interactive documentation which visualizes each API function in a fun manner:

View the interactive API


Bezier-rs is built for the needs of Graphite, an open source 2D vector graphics editor. We hope it may be useful to others, but presently Graphite is its primary user. Pull requests are welcomed for new features, code cleanup, ergonomic enhancements, performance improvements, and documentation clarifications.

The library currently provides functions dealing with single Bézier curve segments and open-or-closed multi-segment paths (which we call subpaths).

In the future, the library will be expanded to include compound paths (multiple subpaths forming a single shape, where the winding order determines inside-or-outside-ness) and operations between paths (e.g. boolean operations, convex hull). Pull requests for these additional features would be highly desirable.

Bezier-rs is inspired by Bezier.js and A Primer on Bézier Curves by Pomax. Bezier-rs is not a port of Bezier.js so the API for single-segment Bézier curves has some differences, and the intention is to offer a broader scope that provides algorithms beyond single curve segments (as noted above) to eventually service full vector shapes.

Terminology

Graphite and Bezier-rs use the following terminology for vector data. These depictions are given for cubic Bézier curves.

Manipulators Curve/Bezier Segment Subpath/Path Open/Closed

Dependencies

~3MB
~93K SLoC