from Hacker News

Flattening Bézier Curves and Arcs

by vg_head on 4/10/24, 12:48 PM with 18 comments

  • by raphlinus on 4/11/24, 3:12 AM

    Cool to see! The tweak suggested in the blog post when you're near the vertex of the parabola is valid, and the implementation that was in Vello did something very similar. This is also the flatten algorithm that's in kurbo[1], and the code for that is probably the most accessible source for the ideas. However, if approaching this again I'd suggest placing a subdivision point at the vertex, which will also handle the degenerate colinear case; I now have reason to believe that the error metric that all this is based on works for monotonic curvature, and can fail otherwise.

    I say "was" as the new version in Vello is much more sophisticated, and handles both flattening and stroke expansion, all on the GPU. A paper is in the works, and I'll post it to HN when it's ready.

    [1]: https://docs.rs/kurbo/latest/kurbo/struct.BezPath.html#metho...

  • by fch42 on 4/11/24, 3:43 PM

    late to the fray, but thanks for posting this!

    "in the old days", books on computer graphics used to be full on "rasterization" techniques - how to convert high-level shapes, whether lines, polygons, circles/ellipses or other curves to pixels, minimising errors while maximising speed.

    Much of that has gone out in favour of "engines" - how to program shaders to do transforms of all sorts.

    While the latter is a big part of what "makes cool graphics cool", it also leaves a gap ... that "immediacy" between the image/shape and the discrete representation in memory is gone.

    Nice to see you're still happy to lift the curtain on it!

  • by ramijames on 4/10/24, 4:56 PM

    I will never understand this