Skip to content

Instantly share code, notes, and snippets.

@5HT
Created April 22, 2014 12:48
Show Gist options
  • Save 5HT/11177762 to your computer and use it in GitHub Desktop.
Save 5HT/11177762 to your computer and use it in GitHub Desktop.
Convert Adobe CreateJS Path to SVG Path
function svgPrim(cjs) {
switch(cjs) {
case 'moveTo': return 'M';
case 'quadraticCurveTo': return 'Q';
case 'lineTo': return 'L';
case 'closePath': return 'Z';
default: return cjs;
}
}
function convertCJStoSVG(insts) {
var path = "";
for (var i=0;i<insts.length;i++) {
var s = svgPrim(insts[i].f.name) + " ";
for (var j=0;j<insts[i].params.length;j++) s += insts[i].params[j].toFixed(2) + " ";
path += s + " ";
}
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment