pathCommands
Tokenizes an SVG path d string into its commands as written, without
resolving them to absolute coordinates. Arc
flags are read as single 0/1 characters, so compact arcs such as
a1 1 0 011 1 tokenize correctly. Stops at the first character that is
not a path command.
Basic example
Section titled “Basic example”Each command keeps its letter, so relative commands stay relative, and its numbers are grouped by segment when the command repeats. The arc’s flags are read as single digits, so a compact arc like a1 1 0 011 1 gives flags 0 and 1 and the endpoint 1, 1.
import {pathCommands} from "@d3plus/math";
pathCommands("M10,20L30 40h5Z");
pathCommands("m0 0 10 10 20-5"); // m [[0,0],[10,10],[20,-5]]
pathCommands("M0,0a1 1 0 011 1");
Parameters
import {pathCommands} from "@d3plus/math";
drequiredstringAn SVG path string (the
dattribute of a<path>).