Vixen
02b45cc4
csharp
public static class EdgeColoring

Decides which channels each edge of a contour contributes to.

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

Remarks

This is the whole idea behind a multi-channel field. A single distance field rounds every corner, because the distance to the nearest edge is smooth across one. Give the two sides of a corner different channels and each channel stays smooth on its own; the median of the three then reconstructs the corner, because two of the three agree on which side of the shape a point is on and the third is the one that rounded.

⚠ Only at a corner. Along a smooth join the two segments must share their channels, or the median sees a discontinuity where the outline has none and the glyph grows a notch.

⚠ Corners are found from the outline's own tangents, never from the flattened chords. Two things go wrong with chords, and this cost two attempts. A curve cut into twenty pieces has nineteen internal joins that each turn a few degrees, and any threshold small enough to catch a shallow real corner calls all of them corners. And even at a genuine segment boundary the two neighbouring chords differ by about one step's worth of curvature, so a smooth join between two curves reads as a corner as well — which is what a circle is made of, and it came out striped.

Methods (1)

  • public static List<ColouredEdge> Colour(GlyphOutline outline, List<Edge> edges)

    Colours a flattened outline, using the outline itself to find the corners.

Used by (1)

  • DistanceFieldVixen.Ui.Text