Get the latest tech news

Flattening Bézier Curves and Arcs


It's possible to flatten Bézier curves into line segments without resorting to recursive subdivision, while maintaining high quality output and memory efficiency. The same properties can be carried out to elliptical arcs, and we obtain three methods that compose extremely well, with which we can flatten every SVG path primitive on demand.

In this blog post I will present three easy ways to convert quadratics, cubics, and elliptical arcs to a sequence of line segments. While the code is made to be simple and easy to read, in a real scenario you can implement flattening for each of these graphics primitives as one big fold, without storing results in temporary lists. Flattening still remains a relevant option though: it’s easy to implement, it gives you the path length almost for free, and it can be made to be efficient, as we’ve seen here.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Bézier Curves

Bézier Curves

Photo of Arcs

Arcs