| 164 | * }[] |
| 165 | */ |
| 166 | export function decomposePath(normalizedPathString: string) { |
| 167 | const commands = normalizedPathString.split(/[^A-Z]/).filter((s) => s !== ""); |
| 168 | const argumentStrings = normalizedPathString.split(/[A-Z]/).slice(1); |
| 169 | return commands.map((command, index) => { |
| 170 | return { |
| 171 | command: command, |
| 172 | arguments: argumentStrings[index].split(",").filter((s) => s !== "").map((s) => parseFloat(s)), |
| 173 | }; |
| 174 | }); |
| 175 | } |
| 176 | |
| 177 | export function numAttr(s: SimpleSelection<void>, a: string) { |
| 178 | return parseFloat(s.attr(a)); |