Vixen
02b45cc4
csharp
public static class PathFlattener

Turns a path's curves into point runs, at a tolerance the caller chooses.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The counterpart of OutlineFlattener for paths rather than glyph outlines, and deliberately not a shared implementation: an outline is flattened into edges that each remember which segment they came from, because a distance field has to find the corners the outline actually has. A path is flattened into contours, because a tessellator needs to know which points are neighbours and a stroke needs to know where a contour ends. The subdivision arithmetic is four lines; the output shapes are the whole difference.

⚠ This is where PathBuilder's decision to keep curves as curves is spent. A path built once and drawn at two zoom levels is flattened twice, at two tolerances, and is right at both — which is exactly what flattening in the builder would have made impossible.

Methods (1)

  • public static void Flatten(IReadOnlyList<PathSegment> segments, int offset, int length, float tolerance, List<Vector2> points, List<Contour> contours)

    Flattens a range of a path's segments.

Used by (2)

  • PathTessellatorTestsVixen.Ui.Tests
  • UiGeometryBuilderVixen.Ui