MCPcopy Create free account
hub / github.com/microsoft/SandDance / pathParse

Function pathParse

docs/app/js/sanddance-app.js:121175–121202  ·  view source on GitHub ↗
(pathstr)

Source from the content-addressed store, hash-verified

121173 /\s|,|###/
121174];
121175function pathParse(pathstr) {
121176 const result = [];
121177 let curr, chunks, parsed, param, cmd, len, i, j, n, m; // First, break path into command sequence
121178 const path1 = pathstr.slice().replace(regexp[0], "###$1").split(regexp[1]).slice(1); // Next, parse each command in turn
121179 for(i = 0, n = path1.length; i < n; ++i){
121180 curr = path1[i];
121181 chunks = curr.slice(1).trim().replace(regexp[2], "$1###$2").replace(regexp[3], "$1###$2").split(regexp[4]);
121182 cmd = curr.charAt(0);
121183 parsed = [
121184 cmd
121185 ];
121186 for(j = 0, m = chunks.length; j < m; ++j)if ((param = +chunks[j]) === param) // not NaN
121187 parsed.push(param);
121188 len = cmdlen[cmd.toLowerCase()];
121189 if (parsed.length - 1 > len) {
121190 const m = parsed.length;
121191 j = 1;
121192 result.push([
121193 cmd
121194 ].concat(parsed.slice(j, j += len))); // handle implicit lineTo (#2803)
121195 cmd = cmd === "M" ? "L" : cmd === "m" ? "l" : cmd;
121196 for(; j < m; j += len)result.push([
121197 cmd
121198 ].concat(parsed.slice(j, j + len)));
121199 } else result.push(parsed);
121200 }
121201 return result;
121202}
121203const DegToRad = Math.PI / 180;
121204const Epsilon = 1e-14;
121205const HalfPi = Math.PI / 2;

Callers 3

customSymbolFunction · 0.70
path$1Function · 0.70
pathEqualFunction · 0.70

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected