├── README.md ├── makeZdogBezier.js └── makeZdogBezier.min.js /README.md: -------------------------------------------------------------------------------- 1 | # makeZdogBezier 2 | A function that accepts an array of bezier points and converts them to a structure that Zdog understands. 3 | 4 | __Usage__ 5 | 6 | - Copy a single path directly from Adobe Illustrator 7 | - Paste it into a text editor 8 | - Copy just the `d` property string from the path (the string in quotes) 9 | - Paste into https://path2bezier.netlify.com/ 10 | - Copy the output and pass it into `makeZdogBezier` 11 | 12 | 13 | __Demo__ 14 | https://codepen.io/chrisgannon/pen/85d369c0252013c8fa925c9af2e38c8f 15 | -------------------------------------------------------------------------------- /makeZdogBezier.js: -------------------------------------------------------------------------------- 1 | function makeZdogBezier(_path) { 2 | let arr = [] 3 | arr[0] = { x: _path[0].x, y: _path[0].y } 4 | for (let i = 1; i < _path.length; i++) { 5 | if (i % 3 == 0) { 6 | var key = 'bezier' 7 | var obj = {} 8 | obj[key] = [ 9 | { x: _path[i - 2].x, y: _path[i - 2].y }, 10 | { x: _path[i - 1].x, y: _path[i - 1].y }, 11 | { x: _path[i].x, y: _path[i].y }, 12 | ] 13 | arr.push(obj) 14 | } 15 | } 16 | return arr 17 | } -------------------------------------------------------------------------------- /makeZdogBezier.min.js: -------------------------------------------------------------------------------- 1 | function makeZdogBezier(a){var c=[];c[0]={x:a[0].x,y:a[0].y};for(var b=1;b