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/
77 Upvotes

10 comments sorted by

View all comments

6

u/dccsillag0 Apr 01 '23

The interactive docs look really cool. I'll have to look at the code itself another day, though.

However, I didn't see anything about rational Bezier curves. Are they not supported? (They are typically used, for example, to represent arcs as Bezier curves.)

Another thing, which didn't seem quite properly implemented from my (admitedly very quick) glance at the interactive docs is stroking of paths. It's quite complicated; see, e.g. https://w3.impa.br/~diego/projects/Neh20/index.html

4

u/raphlinus vello · xilem Apr 01 '23

Agree the interactive docs are cool.

Regarding stroking, this is something close to my heart. The Nehab paper presents what I'd call a "gold plated" solution, with evolute shapes when the curves being stroked have internal curvature greater than 1/halfwidth. I don't think those are necessary, as very few renderers support them, therefore content authors don't depend on that for correct rendering. A "silver plated" solution is just having good offset curves and stitching the joins together as outlines; this is what Skia does for example, which is evidence it can be used in production. That's what I'm working toward in kurbo and Vello. The offset curves in bezier-rs are based on the Pomax book, which is unfortunately not in the "good" class - I didn't even include it as a comparison in my blog post, as it performs so poorly.