Function kurbo::fit_to_bezpath

source ·
pub fn fit_to_bezpath(source: &impl ParamCurveFit, accuracy: f64) -> BezPath
Expand description

Generate a Bézier path that fits the source curve.

This function is still experimental and the signature might change; it’s possible it might become a method on the ParamCurveFit trait.

This function recursively subdivides the curve in half by the parameter when the accuracy is not met. That gives a reasonably optimized result but not necessarily the minimum number of segments.

In general, the resulting Bézier path should have a Fréchet distance less than the provided accuracy parameter. However, this is not a rigorous guarantee, as the error metric is computed approximately.

When a higher degree of optimization is desired (at considerably more runtime cost), consider fit_to_bezpath_opt instead.