Skip to content

Instantly share code, notes, and snippets.

@tkazec
Created February 10, 2012 20:59
Show Gist options
  • Save tkazec/1792843 to your computer and use it in GitHub Desktop.
Save tkazec/1792843 to your computer and use it in GitHub Desktop.
(function () {
var e = this.requestAnimationFrame || this.webkitRequestAnimationFrame || this.mozRequestAnimationFrame || this.msRequestAnimationFrame || this.oRequestAnimationFrame || function (g) { setTimeout(g, 1E3 / 60) },
f = Math,
l = f.PI,
m = f.floor,
n = f.random,
o = c.width = 960,
r = c.height = 540,
u = [],
v = 0;
function w(g, p, d, x, i, j, h) {
for (var q = [], k = "#" + "F20,F0F,F6B,C18,408,800".split(",")[m(6 * n())]; j--;) {
var s = 2 * l * n(),
t = x * n();
q.push({
x: g,
y: p,
a: t * f.cos(s),
b: t * f.sin(s),
d: 0.97 + (i - 100) / 1E3,
c: d + m(6 * n()),
e: k
})
}
setTimeout(function () {
u = u.concat(q);
v--
}, h * (1E3 / 60))
}
(function y() {
if (!u.length && !v) for (var p = v = m(6 * n()); p--;) w(130 + m(701 * n()), 130 + m(151 * n()), 5 + m(16 * n()), 4 + m(7 * n()), 70 + m(40 * n()), 50 + m(201 * n()), m(150 * n()));
u.forEach(function (d, p) {
d.x += d.a;
d.y += d.b;
d.a *= d.d;
d.b *= d.d;
d.y += 1.1;
a.fillStyle = !m(4 * n()) ? "rgba(256,256,256,.8)" : d.e;
var i = d.x,
j = d.y,
h = d.c,
q = 0.48 * h,
k = 0.24 * h,
h = 0.336 * h;
a.beginPath();
a.moveTo(i - q, j);
a.lineTo(i, j + q);
a.arc(i + k, j - k, h, 0.25 * l, 1.25 * l, !0);
a.arc(i - k, j - k, h, 1.75 * l, 0.75 * l, !0);
a.fill();
0.1 > (d.c *= d.d) && u.splice(p, 1)
});
a.fillStyle = "rgba(0,0,0,.3)";
a.fillRect(0, 0, o, r);
e(y)
})();
c.onclick = function (g) {
v++;
w(g.pageX - this.offsetLeft, g.pageY - this.offsetTop, 5 + m(16 * n()), 4 + m(7 * n()), 70 + m(40 * n()), 50 + m(201 * n()), 0)
};
b.onkeypress = function () {
[
[480, 350],
[430, 300],
[530, 300],
[380, 250],
[580, 250],
[360, 200],
[480, 200],
[600, 200],
[410, 160],
[550, 160]
].forEach(function (g) {
v++;
w(g[0], g[1], 50, 3, 50, 100, 0)
})
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment