frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Bezier-rs – algorithms for Bézier segments and shapes

https://graphite.rs/libraries/bezier-rs/
193•jarek-foksa•4d ago

Comments

Syzygies•14h ago
I'm hoping to code Bezier animation in OCaml/F# in four dimensional space time, with a moving vantage point. Offload rendering each time slice frame to worker threads.

I'm surprised Bezier-rs is all about curves. Sure, fonts, but I can't be alone here in seeing curves as a special case.

It's easy as a pure mathematician to write off Bezier theory as "specialized" but it's simply the right way to work with polynomials on a simplex.

ttd•5h ago
If you're not restricted to Bezier for graphics (it's a very common choice as the path primitive for vector graphics), there are other classes of curves that you may find are a better fit. In particular, I think animations typically feel better if they move at constant speed - which is nontrivial with Bezier curves because they do not have an exact closed-form arc length parameterization. Something like pythagorean hodographs could be a better fit for your application.

I am not a mathematician though, so if you have other insight I'd be glad to hear it.

ttoinou•4h ago
Instead of using closed form, they can easily computed with the approximation of the curve with segments, and you place the points where there is most curvature or where the 1st derivative isn't close to zero
ttd•1h ago
Yes - but there are other curve classes (like P-H) that have an exact solution and don't need approximation. Bezier curves have tons of nice properties but also a lot of shortcomings, for example not being able represent conic sections like circles and ellipses without introducing weighting (rationals), which complicate computations even further. So, depending on what you're doing with them, it's worth exploring other curve types IMO.
shmerl•14h ago
Is the documentation using the library itself for visualizations?
LoganDark•10h ago
Yep, WASM
Nicole9•8h ago
Wasm in the browser?
formerly_proven•8h ago
wasm = WebAssembly = a simple stack-based VM with one flat heap for memory.
bravesoul2•7h ago
Sure... but people are running Wasm on the server side too so fair question.
tialaramex•5h ago
Barely, this is Rust, so if you're on a server you can just... use that already ?
shmerl•4h ago
That's neat!
continuational•13h ago
Very neat. I'm not sure if I missed it, but is there any way to get n equidistant points on the curve?

E.g. for moving an object at constant speed along the curve.

jamwaffles•13h ago
There is indeed: Bezier::compute_lookup_table[1]. You'll want to use a `TValueType` of `Euclidean` to get equidistant points.

[1]: https://docs.rs/bezier-rs/latest/bezier_rs/struct.Bezier.htm...

pjmlp•12h ago
Great example, this is the kind of stuff that we could make use of interactive documents for, and not bend them into applications.
Fraterkes•7h ago
Almost even more interesting is the Bezier Boolean-Operations lib they use (it’s a rewrite of Pathbool.js (https://github.com/r-flash/PathBool.js) in Rust)

https://github.com/GraphiteEditor/Graphite/tree/master/libra...

There’s not a ton of robust curve boolean libs out there that aren’t just part of some huge package of tools. This is the only one I know of that isn’t Js.

(Edit: added a link)

QuantumNomad_•7h ago
Link to the code for the mentioned Rust path-bool crate:

https://github.com/GraphiteEditor/Graphite/tree/master/libra...

tonyedgecombe•7h ago
Interesting, I’m writing some code to find the interception of two clipping paths at the moment. I can’t use this because I have a no dependency rule but will take a look.
Fraterkes•4h ago
In case you end up coming up with your own solution: this is one of the best collections of info for what is currently out there Ive seen: https://github.com/linebender/kurbo/issues/277
stuaxo•2h ago
Oh, that's definitely interesting - would be good for creative coding.

I could do with python bindings for this.

meindnoch•1h ago
"The boolean operations are implemented using a graph-based approach. After the parsing the input, self-intersecting cubic beziers curves are simplified. Then the intersection points between all edges are calculated. These are then turned into a graph representation where every intersection becomes a new vertex. We then apply edge contractions to remove vertices with a degree of 2 to compute the graph minor. At this stage, identical edges are deduplicated. Because we are ultimately interested in the faces of the graph to decide if they should be included in the final output, we then compute the dual graph in which the faces become vertices and vertices become the new faces. That dual structure is then used to determine which faces (dual vertices) should be included in the final output."

This would be such a pain in the ass to implement with good precision and performance.

childintime•5h ago
Bezier curves in painting software never gave me the results I wanted. And I mean never. I sincerely wonder who succeeds at using them?

From these graphs I see that I always wanted the simple Quadratic version, and would use 2 of them in sequence to approximate a Cubic version. That would be so much easier. But if the software could allow me to adjust the midpoint, and maintain a smooth transition, that would be perfect. I think.

So I basically wish for a different interface, one that has more thought put into it. Now it's a "give access to the parameters, and be done with it" kind. As if novices don't have the need for a nice smooth curve between known points.

panzerboiler•5h ago
A Bézier curve is not an interpolating spline. It is a parametric curve defined by a set of control points, which the curve typically does not pass through (except the first and last points). Bézier curves exhibit local control (changing a control point influences only a portion of the curve, especially in piecewise Bézier constructions). Interpolating splines may seem more user-friendly at first, since the curve passes exactly through all the given points. However, this can lead to unintuitive behavior: modifying a single point can cause global changes in the curve, including in areas far from the edited point. In some cases, these changes can be drastic, making precise control difficult or impossible. I may be biased by my 20+ years of graphic design work, but I prefer the precision and control given by Bézier curves.
ttoinou•4h ago
The person you're answering to is not suggesting interpolating curves. Piecewise quadratic bezier curves are very local, two quadratic bezier curves can approximate well a 3rd degree bezier curve
panzerboiler•4h ago
I probably misunderstood their message. By the way, two quadratic curves can approximate well a tiny subset of what a cubic bezier can represent. The number of quadratics required in the general case can grow quite substantially, very quickly.
ttoinou•3h ago
You're right we probably need at least 3 quadratic bezier curves to cover most uses cases of 3rd degree bezier curves. (In general, not all shapes of 3rd degree bezier curves are used in the wild, that would lead to too much deformation and impossible paths).

But I agree with the OP, artists might only need new tools that use quadratic bezier curves in a different ways

WillAdams•4h ago
A markedly different UI is that of FutureWave SmartSketch which has been reimplemented in

https://www.wickeditor.com/

For Beziér curves remember the basics:

- put nodes at extrema and points of inflection (extreme left/right, top/bottom, middle of _S_ curve)

- rule of 30 --- off curve nodes should be ~30% away from the matching on curve node for smoothest appearance unless the shape one is trying to achieve dictates a different placement

phkahler•4h ago
You might like the spline tool in Solvespace:

https://solvespace.com/

If you just do a start/end point it will create a cubic with 2 endpoints and 2 control points. But if you drop a whole series of points (up to 12 I think) it will create a curve that passes though all of them. This is done by internally creating a bunch of cubic splines where the control points are automatically positioned and not shown. You still get 2 control points for the derivatives at the ends, unless you create a closed loop.

__jonas•5h ago
This looks really nice!

I’m currently looking for a nice implementation of stroke expansion (here called outlining) that I can run in the browser, this seems like a good option besides skia (pathkit)[0] and vello/kurbo[1].

Ideally I’d love to be able to expand in a non-uniform way, similar to what Metafont does for bitmap fonts, or what Inkscape allows with its power stroke effect, or even just with a non-uniform ‘nib’ as is possible with FontForge[2].

This doesn’t seem to be something that these bezier libraries generally offer which is understandable, probably a rather niche goal.

[0] https://skia.org/docs/user/modules/pathkit/

[1] https://doc.servo.org/kurbo/stroke/index.html

[2] https://fontforge.org/docs/techref/stroke.html

graphviz•4h ago
Any ideas how these primitives could be used to implement an edge router for drawing natural-looking curves around obstacles in diagrams, as an improvement on the 25-year-old solver in graphviz https://dpd.cs.princeton.edu/Papers/DGKN97.pdf?
phkahler•4h ago
If they could extend it to rational Beziers it might be useful for CAD applications. We have a subset of these in C++ as the core of Solvespace. This is one of my favorite source files:

https://github.com/solvespace/solvespace/blob/master/src/srf...

viggity•3h ago
Anytime béziers are mentioned on HN, I feel compelled to share these absolutely incredible videos from Freya Holmér

https://www.youtube.com/watch?v=jvPPXbo87ds (73 minutes)

https://www.youtube.com/watch?v=aVwxzDHniEw (24 minutes)

nartho•3h ago
So this is a long shot but, as a software engineer lacking in the math department who has slowly been trying to improve calculus and geometry, what are some good resources/requirements to get to a point where I can implement something like that ?
ajs1998•2h ago
Maybe not exactly what you're looking for, but this video is excellent. And her other video on Splines is also great.

https://www.youtube.com/watch?v=aVwxzDHniEw

junon•1h ago
+1, Freya's courses are always awesome.
LegionMammal978•2h ago
This library has a very interesting algorithm for computing the curve point closest to a given point, seemingly based on a root-finder that doesn't need any complex numbers. Does anyone know of any resources about such an algorithm?
CyLith•1h ago
The library only solves up to cubic equations, and the comments have a link to the following page: https://momentsingraphics.de/CubicRoots.html

For general polynomials, it matters a great deal in what basis it is represented. The typical monomial basis is usually not the best from a numerical standpoint. I am aware of some modern methods such as this: https://arxiv.org/pdf/1611.02435

For polynomials expressed in e.g. a Bernstein basis, there are often much faster and stable tailored methods working solving for the eigenvalues of a companion matrix of a different form.

LegionMammal978•46m ago
That doesn't sound right, nearest-point queries for cubic Béziers take at least a quintic solver, and this library uses a subdivision-based algorithm with Bernstein polynomials that is seemingly designed to work with any degree [0]. (Or at least, it doesn't have any code that complains when the degree is too large.)

[0] https://github.com/GraphiteEditor/Graphite/blob/master/libra...

brcmthrowaway•2h ago
If only you could make a perfect circle out of bezier curves.. then P=NP
Sharlin•2h ago
With rational Bézier curves you can!

Nginx Introduces Native Support for Acme Protocol

https://blog.nginx.org/blog/native-support-for-acme-protocol
201•phickey•2h ago•82 comments

FFmpeg 8.0 adds Whisper support

https://code.ffmpeg.org/FFmpeg/FFmpeg/commit/13ce36fef98a3f4e6d8360c24d6b8434cbb8869b
625•rilawa•8h ago•237 comments

I chose OCaml as my primary language

https://xvw.lol/en/articles/why-ocaml.html
22•nukifw•23m ago•5 comments

Launch HN: Golpo (YC S25) – AI-generated explainer videos

https://video.golpoai.com/
20•skar01•1h ago•29 comments

Cross-Site Request Forgery

https://words.filippo.io/csrf/
16•tatersolid•57m ago•1 comments

April Fools 2014: The *Real* Test Driven Development

https://testing.googleblog.com/2014/04/the-real-test-driven-development.html
16•omot•42m ago•3 comments

OpenIndiana: Community-Driven Illumos Distribution

https://www.openindiana.org/
48•doener•3h ago•34 comments

So what's the difference between plotted and printed artwork?

https://lostpixels.io/writings/the-difference-between-plotted-and-printed-artwork
115•cosiiine•5h ago•44 comments

ReadMe (YC W15) Is Hiring a Developer Experience PM

https://readme.com/careers#product-manager-developer-experience
1•gkoberger•1h ago

Coalton Playground: Type-Safe Lisp in the Browser

https://abacusnoir.com/2025/08/12/coalton-playground-type-safe-lisp-in-your-browser/
68•reikonomusha•3h ago•18 comments

Pebble Time 2* Design Reveal

https://ericmigi.com/blog/pebble-time-2-design-reveal/
60•WhyNotHugo•3h ago•22 comments

This website is for humans

https://localghost.dev/blog/this-website-is-for-humans/
301•charles_f•3h ago•152 comments

DoubleAgents: Fine-Tuning LLMs for Covert Malicious Tool Calls

https://pub.aimind.so/doubleagents-fine-tuning-llms-for-covert-malicious-tool-calls-b8ff00bf513e
53•grumblemumble•4h ago•17 comments

New treatment eliminates bladder cancer in 82% of patients

https://news.keckmedicine.org/new-treatment-eliminates-bladder-cancer-in-82-of-patients/
145•geox•3h ago•46 comments

The Mary Queen of Scots Channel Anamorphosis: A 3D Simulation

https://www.charlespetzold.com/blog/2025/05/Mary-Queen-of-Scots-Channel-Anamorphosis-A-3D-Simulation.html
51•warrenm•5h ago•13 comments

A case study in bad hiring practice and how to fix it

https://www.tomkranz.com/blog1/a-case-study-in-bad-hiring-practice-and-how-to-fix-it
48•prestelpirate•1h ago•42 comments

We caught companies making it harder to delete your personal data online

https://themarkup.org/privacy/2025/08/12/we-caught-companies-making-it-harder-to-delete-your-data
183•amarcheschi•4h ago•43 comments

How Stock Options Work

https://web.stanford.edu/class/e145/2007_fall/materials/stockoptions.html
19•jdcampolargo•56m ago•0 comments

Claude says “You're absolutely right!” about everything

https://github.com/anthropics/claude-code/issues/3382
492•pr337h4m•11h ago•391 comments

Mesmerizing Hypnoloid, a Kinetic Desktop Sculpture

https://www.core77.com/posts/138054/This-Mesmerizing-Hypnoloid-a-Kinetic-Desktop-Sculpture
7•surprisetalk•3d ago•0 comments

Honky-Tonk Tokyo (2020)

https://www.afar.com/magazine/in-tokyo-japan-country-music-finds-an-audience
15•NaOH•3d ago•3 comments

Gartner's Grift Is About to Unravel

https://dx.tips/gartner
56•mooreds•2h ago•32 comments

Tesla Diner Drops Most Menu Options and Cuts Hours Just Weeks After Opening

https://www.jalopnik.com/1938650/tesla-diner-drops-most-menu-options-cuts-hours/
9•raattgift•31m ago•4 comments

Nearly 1 in 3 Starlink satellites detected within the SKA-Low frequency band

https://astrobites.org/2025/08/12/starlink-ska-low/
158•aragilar•10h ago•138 comments

Claude Sonnet 4 now supports 1M tokens of context

https://www.anthropic.com/news/1m-context
1244•adocomplete•1d ago•658 comments

Pebble Time 2 Design Reveal [video]

https://www.youtube.com/watch?v=pcPzmDePH3E
125•net01•5h ago•51 comments

Bezier-rs – algorithms for Bézier segments and shapes

https://graphite.rs/libraries/bezier-rs/
193•jarek-foksa•4d ago•39 comments

F-Droid build servers can't build modern Android apps due to outdated CPUs

366•nativeforks•13h ago•237 comments

The Rock Art of Serrania De La Lindosa

https://www.earthasweknowit.com/pages/serrania_de_la_lindosa_rock_art
23•kkoncevicius•4d ago•2 comments

Supporting org.apache.xml.security in graalVM

https://guust.ysebie.be/blog/supporting-apache-xml-security-algorithms.html
23•whizzx•5h ago•3 comments