Vixen
02b45cc4
csharp
public static class SvgPath

Reads SVG path data — the d attribute — into a PathBuilder.

Read the guide page for this →

Remarks

What every icon set on earth is distributed as. Material, Lucide, Feather, Fluent, Bootstrap and Phosphor all ship a 24-square grid and a string per glyph, and until this existed the only way into this engine was to transcribe one into PathBuilder.LineTo calls by hand — which is why the editor's icon set is two dozen shapes drawn from line segments and why [EditorIcon] was documented as a mechanism that could not be built. It is a hundred and fifty lines. See EditorIcon.

⚠ Every command in the grammar, including the two that are not curves or lines. H/V are what a rectangle is written with and A — the elliptical arc — is what a rounded corner is written with, and an icon set that dropped either would render about a third of Material Symbols as a squashed polygon. The arc is the long part of this file and it is F.6.5 of the SVG specification, converted to centre parametrisation and emitted as cubics.

⚠ Relative commands are resolved here and not carried. A PathSegment holds absolute points, so h20 becomes a line to the pen plus twenty — which means the pen has to be tracked through every command including Z, whose end point is where the contour started rather than where the path did. Getting that one wrong shows as every closed subpath after the first landing in the wrong place.

⚠ The smooth commands need the previous control point, and its reflection is only defined after a curve of the same family. S after a line reflects nothing and the control point is the pen itself — the specification's own rule, and the one a from-memory implementation always gets wrong, because the wrong answer only shows on paths that mix lines and smooth curves.

Methods (2)

  • public static PathBuilder Parse(string data)

    Reads path data.

  • public static PathBuilder? TryParse(string? data)

    Reads path data, answering rather than throwing.

Used by (3)

  • SvgPathTestsVixen.Ui.Tests
  • EditorIconAttributeVixen.Editor.Ui
  • MaterialIconsVixen.Editor.App