var g=s=0,h=[],k=Y=x=y=p=C=0,l=a.width,m=a.height,n=Math;for(e in c)c[e[0]+e[2]+(e[6]||"")]=c[e];var q=[],r=c.ceR(0,0,0,0,0,l+m);r.addColorStop(0,"#1E80C2");r.addColorStop(1,"transparent");function t(f){return n.random()*(f-40)+20}onmousemove=function(f){x=f.pageX;y=f.pageY};
function u(){with(c){g++;s=g/9;k+=(x-k)/20;Y+=(y-Y)/20;50>h.length&&h.push([k,Y]);globalAlpha=0.7;fillStyle=r;arc(0,0,l+m,0,7);fl();0==g%2&&h.shift();lineWidth=5;strokeStyle="hsl("+t(h.length)+",90%,50%)";for(var f=0;f<h.length-1;f++)bga(),mv(h[f][0],2*n.cos(-f+s)-(h[f][1]-h[f][1])/9+h[f][1]-9),ln(h[f+1][0],2*n.cos(-f+s)-(h[f+1][1]-h[f][1])/9+h[f+1][1]-9),sr(),coa();0==g%50&&q.push([t(l),t(m),t(80),t(200)]);for(f=0;f<q.length;f++)C=q[f],strokeStyle=50<C[2]?"black":"hsl("+C[3]+",90%,50%)",bga(),arc(3*
n.cos(s)+C[0],3*n.sin(s)+C[1],C[2],0,7),coa(),sr(),n.sqrt((k-C[0])*(k-C[0])+(Y-C[1])*(Y-C[1]))<C[2]&&(q.splice(f,1),p++,50<C[2]&&(p=0,h=[]));font="30px arial";fillStyle="#fff";flx(p,20,40)}window.requestAnimationFrame(u)}u();
// Full source available on GitHub: https://github.com/ThibWeb/js1k-2014
// Timer and smoothTimer;
var t = s = 0;
var positions = [];
// Current positions and points.
var X = Y = x = y = p = C = 0;
var w = a.width;
var h = a.height;
var M = Math;
for (e in c) c[e[0]+e[2]+(e[6]||'')] = c[e];
var circles = [];
// create radial gradient
var grd = c.ceR(0, 0, 0, 0, 0, w + h);
grd.addColorStop(0, '#1E80C2');
grd.addColorStop(1, 'transparent');
function rand(high) {
return M.random() * (high - 40) + 20;
}
onmousemove = function (e) {
x = e.pageX;
y = e.pageY;
};
function loop() {
with(c) {
t++;
s = t / 9;
// Fill slicer.
X += (x - X) / 20;
Y += (y - Y) / 20;
if (positions.length < 50) {
positions.push([X, Y]);
}
// Draw background.
globalAlpha = .7;
fillStyle = grd;
arc(0, 0, w + h, 0, 7);
fl();
// Remove elt from slicer.
if (t % 2 == 0) {
positions.shift();
}
// Draw slicer.
lineWidth = 5;
strokeStyle = 'hsl(' + rand(positions.length) + ',90%,50%)';
for (var i= 0; i < positions.length - 1; i++) {
bga();
mv(positions[i][0], M.cos(-i + s) * 2 - (positions[i][1]-positions[i][1])/9 + positions[i][1] - 9);
ln(positions[i+1][0], M.cos(-i + s) * 2 - (positions[i+1][1]-positions[i][1])/9 + positions[i+1][1] - 9);
sr();
coa();
}
// Pop circles.
if (t % 50 == 0) {
circles.push([rand(w), rand(h), rand(80), rand(200)]);
}
for (var i = 0; i < circles.length; i++) {
C = circles[i];
// Draw circles.
strokeStyle = C[2] > 50 ? 'black' : 'hsl(' + C[3] + ',90%,50%)';
bga();
arc(M.cos(s) * 3 + C[0], M.sin(s) * 3 + C[1], C[2], 0, 7);
coa();
sr();
// Check for circle collision.
if (M.sqrt((X-C[0])*(X-C[0]) + (Y-C[1])*(Y-C[1])) < C[2]) {
circles.splice(i, 1);
p++;
if (C[2] > 50) {
p = 0;
positions = [];
}
}
}
font = '30px arial';
fillStyle = '#fff';
flx(p, 20, 40);
}
window.requestAnimationFrame(loop);
}
loop();