Email or username:

Password:

Forgot your password?
Raph Levien

I've done some work in the past few weeks to land high quality Bézier path simplification in kurbo and make it more robust. It's not completely done yet (explicit corner handling is a todo), but it does a pretty good job with one of our test cases. Here it has fit the source curve (blue) with 41 Bézier segments. I believe it is close to the optimum possible solution for the error tolerance. New PR: github.com/linebender/kurbo/pu

This will be useful both for fonts and design tools for vector graphics.

3 comments
bazzargh

@raph I'm just the peanut gallery here but I have to ask... what's going on at these two points, on the lower edge? normally I'd expect the simplification to be smoother, but these seem to be surprisingly sharp turns on a smooth section of the input curve? I had to double check, are the source and output curves swapped? (just asking because they jumped out, incredibly impressed with this work)

Raph Levien

@bazzargh Good spotting! That probably deserves more investigation. The curve is technically continuous there (not visible in the bitmap rendering), and appears to be within error tolerance, but I'm not sure yet whether it's actually the solution that minimizes Fréchet distance or whether it's finding a case where the error metric is underestimated.

Fréchet is cool but doesn't guarantee smoothness, perhaps for rigorous work a more sophisticated error metric would be better.

Raph Levien

@bazzargh I've done a bit more analysis, and believe that the problem is that optimizing for Fréchet gives you these bumps. I am exploring two approaches - one is to use an error metric that prioritizes smoothness, but the simpler is just to disallow cubic Béziers that have near-cusp behavior. Very likely this will be a blog post.

Go Up