Documentation
    Preparing search index...

    Function formatSvgPathData

    • Writes a §51 Path as an SVG d attribute (§50 "SVG export").

      formatSvgPathData(new Path().moveTo(0, 0).lineTo(10, 0).close());
      // "M 0 0 L 10 0 Z"

      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.

      Parameters

      Returns string

      the d attribute's value, with no leading or trailing space