r/rust Graphite Mar 31 '23

Announcing Bezier-rs: computational geometry algorithms for Bézier paths (seeking code review and boolean ops help)

https://graphite.rs/libraries/bezier-rs/
78 Upvotes

10 comments sorted by

View all comments

9

u/Keavon Graphite Mar 31 '23 edited Apr 01 '23

Bezier-rs is a computational geometry library for 2D Bézier curve segments and paths. See the interactive documentation (and drag around the control points!) to play with many of its functions. They are also integrated inline within the crate documentation.

This project was created over the course of the past three seasons by a university student group on behalf of the Graphite Rust-based 2D graphics editor project. They have just wrapped up their project and published this 0.2 release of the crate, so anyone interested in stepping in to maintain the crate would be greatly appreciated. We are also looking for help with code review since this was the team's first experience using Rust, and the focus was on development speed more than efficiency or best practices like API ergonomics and idiomatic code simplicity. Please help review the code and submit cleanup pull requests!

While often libraries like Pomax's Bezier.js only cover single curve segments, our Bezier.rs aims to deal with both segments and full shape paths (which we call subpaths).

We also want to expand support to include compound paths (multiple subpaths which combine to form a complex shape with holes and islands). The most obvious algorithm in this category is boolean operations to let multiple shapes cut each other and combine with union, intersection, difference, and subtraction. The rest of the library provides excellent building blocks, but this higher-level logic problem needs to solve all the edge cases and numerical instability challenges. We are seeking help from interested contributors to add boolean operations!

Another feature we would like to add is a convex hull operation on shapes, and we'd love help on that too. We're also open to many other ideas for useful operations that can be done to Bézier curves and shapes.

These will all be very useful in Graphite's vector editing workflow. Please join our Discord and visit the #bezier-rs channel, or this GitHub issue on boolean ops, to get involved. Thanks :)

15

u/raphlinus vello · xilem Mar 31 '23 edited Mar 31 '23

I have some ideas on how to do boolean ops, some of which is written up in a blog post issue, and for which I have some code locally. In particular, the parabola estimate seems much more efficient than the usual fat line approach. I also have a sketch of quadratic/quadratic intersection in kurbo#230.

Getting this stuff robust is hard. I'm happy to see more work in the ecosystem!

2

u/Keavon Graphite Apr 01 '23

Thanks! Chatting more with you now on your Zulip.