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.
This function is intended for use when the source curve is piecewise continuous, with the discontinuities reported by the cusp method. In applications (such as stroke expansion) where this property may not hold, it is up to the client to detect and handle such cases. Even so, best effort is made to avoid infinite subdivision.
When a higher degree of optimization is desired (at considerably more runtime cost),
consider fit_to_bezpath_opt
instead.