any path, including an empty one (which yields "")
Optionaloptions: SvgPathFormatOptions
optional SvgPathFormatOptions.precision; omitted
output is identical to the lossless String(value) writer
the d attribute's value, with no leading or trailing space
Writes a §51 Path as an SVG
dattribute (§50 "SVG export").Absolute uppercase commands, single spaces, no commas, and every number as
String(value)— lossless and, unlike a fixed-decimal format, exactly specified by ECMA-262. Pass{ precision }to opt into a rounded writer; omitting it keeps this default, so the determinism golden does not move.Coordinates are written verbatim, so the output is in the path's own space: a path authored in §7a's Y-up world renders mirrored in an SVG viewer unless the caller flips it first. That is the same decision parseSvgPathData makes, in the other direction.
Round trip: for a path of moves, lines, quadratics, cubics and closes,
parseSvgPathData(formatSvgPathData(path))reproduces the command list bit for bit. For a path containing arcs it reproduces the shape to within a few ulps — SVG stores an arc by its endpoints and its rotation in degrees, and neither conversion is exact.