Created
April 22, 2014 12:48
-
-
Save 5HT/11177762 to your computer and use it in GitHub Desktop.
Convert Adobe CreateJS Path to SVG Path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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