Expand description
§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.
Structs§
- Struct to represent optional parameters that can be passed to the
arcs
function. - Representation of a bezier curve with 2D points.
- Struct to represent the circular arc approximation used in the
arcs
bezier function. - Structure used to represent a single anchor with up to two optional associated handles along a
Subpath
- Struct to represent optional parameters that can be passed to the
project
function. - Structure used to represent a path composed of Bezier curves.
- Iteration structure for iterating across each curve of a
Subpath
, using an intermediateBezier
representation.
Enums§
- Struct used to represent the different strategies for generating arc approximations.
- Representation of the handle point(s) in a bezier segment.
- Enum to represent the cap type at the ends of an outline As defined in SVG: https://www.w3.org/TR/SVG2/painting.html#LineCaps.
- Represents the shape of the join between two segments of a path which meet at an angle. Bevel provides a flat connection, Miter provides a sharp connection, and Round provides a rounded connection. As defined in SVG: https://www.w3.org/TR/SVG2/painting.html#LineJoin.
- A structure which can be used to reference a particular point along a
Bezier
. Assuming a 2-dimensional Bezier is represented as a parametric curve defined by components(x(f(t), y(f(t))))
, this structure defines variants forf(t)
.
Traits§
- An id type used for each ManipulatorGroup.