Skip to content

Instantly share code, notes, and snippets.

@steel1990
Created October 23, 2014 19:44
Show Gist options
  • Save steel1990/8c9c943b27a59c14587a to your computer and use it in GitHub Desktop.
Save steel1990/8c9c943b27a59c14587a to your computer and use it in GitHub Desktop.
var x = [{x:49.25,y:27.05,rotation:0,scaleX:1,scaleY:1},{x:54.15,y:28.8,rotation:0,scaleX:1,scaleY:1},{x:56.05,y:29.7,rotation:-0.0008697509765625,scaleX:1,scaleY:1},{x:56.15,y:27.1,rotation:-0.500946044921875,scaleX:1.00006103515625,scaleY:1.00006103515625},{x:55.7,y:26.85,rotation:-1.0009307861328125,scaleX:1.000030517578125,scaleY:1.000030517578125},{x:41.75,y:23.35,rotation:0,scaleX:1,scaleY:1},{x:33.3,y:20.8,rotation:0,scaleX:1,scaleY:1},{x:30,y:20.55,rotation:0,scaleX:1,scaleY:1},{x:29.85,y:22.75,rotation:-1.00006103515625,scaleX:1,scaleY:1},{x:29.4,y:24.7,rotation:-1.975921630859375,scaleX:1.000030517578125,scaleY:1.000030517578125},{x:29.25,y:24.95,rotation:-1.2517547607421875,scaleX:1.0000152587890625,scaleY:1.0000152587890625},{x:29.35,y:24.45,rotation:-1.0009307861328125,scaleX:1.000030517578125,scaleY:1.000030517578125},{x:29.25,y:24.05,rotation:-1.99951171875,scaleX:1.0000457763671875,scaleY:1.0000457763671875},{x:29.65,y:23.15,rotation:-2.23785400390625,scaleX:1.0000457763671875,scaleY:1.0000457763671875},{x:30.05,y:22.5,rotation:-1.0009307861328125,scaleX:1.0000152587890625,scaleY:1.0000152587890625},{x:29.75,y:24,rotation:-1.0009307861328125,scaleX:1.0000152587890625,scaleY:1.0000152587890625},{x:28.7,y:25.75,rotation:-2.21514892578125,scaleX:1.000030517578125,scaleY:1.000030517578125},{x:29.95,y:22.55,rotation:-0.76318359375,scaleX:0.999969482421875,scaleY:0.999969482421875},{x:30.3,y:20.55,rotation:0,scaleX:1,scaleY:1},{x:30.25,y:19.85,rotation:0,scaleX:1,scaleY:1}];
var tpl = '{p}% { transform: translateX({x}em) translateY({y}em) scaleX({scaleX}) scaleY({scaleY}) rotate({rotation}deg); }'
function round (d) {
return Math.round(d * 1000) / 1000;
}
var lastD = null;
var cssArr = [];
x.forEach(function(d, i) {
d.x = round(d.x/40);
d.y = round(d.y/40);
d.scaleX = round(d.scaleX * 0.88);
d.scaleY = round(d.scaleY * 0.88);
d.p = round(100/19*i);
d.rotation = round(d.rotation);
if (lastD) {
lastD.p = round(d.p - 0.001);
cssArr.push(KISSY.substitute(tpl, lastD));
}
lastD = d;
cssArr.push(KISSY.substitute(tpl, d));
});
console.log(cssArr.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment