Path.Simplify Method

Applies to: Graphics Mill 12.1, 6.x-12.x (may differ)

Removes the points of the path that lie close to the line through their neighbors.

Namespace: Aurigma.GraphicsMill.Drawing
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

C#
public void Simplify(
	float tolerance
)

Parameters

tolerance

Type: System.Single

The largest allowed distance from a removed point to the line, in path units. Must be greater than 0.

Remarks

This method uses the Douglas-Peucker algorithm. The ends of open subpaths stay. Curves are converted to polylines first.

Examples

C#
// A noisy line, for example, a line drawn by hand.
var path = new Path();
for (int i = 0; i <= 40; i++)
{
    float x = 15 + i * 3;
    float y = 75 - 45 * (float)System.Math.Sin(i * System.Math.PI / 20) + ((i * 7) % 5 - 2);

    if (i == 0)
        path.MoveTo(x, y);
    else
        path.LineTo(x, y);
}

var original = new Path(path);

// Remove the points that are closer than 3 units to the line through their neighbors.
path.Simplify(3f);

The original path and the simplified path.

The original path and the simplified path.

Exceptions

Exception Condition
System.ArgumentOutOfRangeException The tolerance is not greater than 0.

See Also

Reference

Manual