function SmoothToCubicBezier(const path: TPathD; pathIsClosed: Boolean; maxOffset: integer = 0): TPathD;

This function uses a custom algorithm to insert CBezier control points into the specified path. The resulting bezier path can then be very easily converted into a flattened path by using the FlattenCBezier function.

The algorithm uses the angle at each vertex to determine the amount of smoothing, with very wide angles being smoothed much more than very narrow angles. The maxOffset parameter can be used to restrict the amount of smoothing applied. When this parameter is zero, smoothing is determined by the size of each angle (as a fraction of 180 degrees) multiplied by half the length of the adjacent edge. When maxOffset is greater than zero, this value specifies the maximum distance allowed for each control point from its adjacent vertex.

maxOffset = 0
maxOffset = 10

There are many applications for path smoothing, but there's one application where path smoothing is particularly useful. When 'vectorizing' raster images, the rough paths that are frequently produced by Vectorize are ideal for smoothing, especially when combined with RamerDouglasPeucker.

Monochrome raster image:
Vectorized, simplified and smoothed:

See Also

RamerDouglasPeucker, Vectorize, FlattenCBezier