flatten comparison
The same curve, cut into straight lines by each of flatten's
methods (the library's own code). Drag the round handles. Gray band: the curve,
drawn as wide as twice the tolerance, so the lines should stay inside it. Blue:
the lines. The marker shows where the lines are furthest from the curve,
measured by dense sampling.
uniform (Wang's formula, Skia)
adaptive (kurbo)
uniform: equal steps along the curve, as many as its sharpest
bend needs (Wang's formula, as in Skia). A proven bound, so it never exceeds the
tolerance, but curves that are sharp in one place and flat elsewhere get more
lines than needed.
adaptive: kurbo's flatten (Raph Levien's method). Lines spaced
by how much the curve bends: dense where it bends, sparse where it's flat.
Cubics are first approximated by quadratics, and one line count is spread over
them, so on cubics it can go past the tolerance (measured up to 2.6×); on
quadratics it stays within about 6%.