Crate bezier_rs

Source
Expand description

repocrates.iodocs.rsinteractive docs

§Bezier-rs

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

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

§View the interactive API


§Deprecation Notice

Bezier-rs was built for the needs of Graphite, an open source 2D graphics editor. The library is now deprecated and has been archived in this repository by extracting its development history from Graphite’s monorepo, with some cleanup in support of its standalone archival.

Graphite has moved to Kurbo as of 2025, which offers superior performance and correctness compared to the naïve and unoptimized algorithms implemented here. However, some algorithms offered by Bezier-rs are not yet available in Kurbo. Note also that Bezier-rs is anchor-centric while Kurbo (like SVG) is segment-centric, meaning paths in Bezier-rs are defined by their anchor points and incoming/outgoing handles, while Kurbo paths are defined by segment commands like move-to, line-to, quadratic-to, and cubic-to.

No further development will continue and 0.5 is the last major version. Interested contributors are encouraged to submit missing algorithms to Kurbo instead.

§Features

Bezier-rs is inspired by Bezier.js and A Primer on Bézier Curves by Pomax. It is not a port, so its API differs and additionally covers paths, not only single Bézier segments. View the interactive documentation or the docs.rs documentation for more feature details.

§Terminology

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

Manipulators Curve/Bezier Segment Subpath/Path Open/Closed

Structs§

ArcsOptions
Struct to represent optional parameters that can be passed to the arcs function.
Bezier
Representation of a bezier curve with 2D points.
CircleArc
Struct to represent the circular arc approximation used in the arcs bezier function.
ManipulatorGroup
Structure used to represent a single anchor with up to two optional associated handles along a Subpath
Subpath
Structure used to represent a path composed of Bezier curves.
SubpathIter
Iteration structure for iterating across each curve of a Subpath, using an intermediate Bezier representation.

Enums§

AppendType
ArcStrategy
Struct used to represent the different strategies for generating arc approximations.
ArcType
BezierHandles
Representation of the handle point(s) in a bezier segment.
Cap
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.
Join
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.
SubpathTValue
TValue
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 for f(t).
TValueType

Traits§

Identifier
An id type used for each ManipulatorGroup.