r=10,MAX=100,drawCoin=(b,d,e,f)=>{c.translate(b,d),s=Math.sin(e);0==s||(c.scale(s,1),c.fillStyle='#DFDF00',c.strokeStyle='#FFFF00',f&&(c.fillStyle='#AAAAAA',c.strokeStyle='#DDDDDD'),c.lineWidth=3,c.beginPath(),c.arc(0,0,r,0,2*Math.PI),c.fill(),c.beginPath(),c.arc(0,0,r,0,2*Math.PI),c.stroke(),c.scale(1/s,1),c.translate(-b,-d))},draw=b=>{for(c.fillStyle='black',c.fillRect(0,0,a.width,a.height),i=0;i<b.length;i++)m=b[i],drawCoin(m.x,m.y,m.t,m.g),m.t+=0.1,m.y+=5,m.y>a.height&&b.splice(i,1);b.length<MAX&&0.2>Math.random()&&b.push({x:Math.floor(Math.random()*(a.width-(r+5)))+r+5,y:r+5,t:10,g:0.1>Math.random()}),requestAnimationFrame(()=>{draw(b)})},coins=[],draw(coins);
r = 10;
MAX = 100;
drawCoin = (x, y, t, g) => {
c.translate(x, y);
s = Math.sin(t);
if (s == 0) {
return;
}
c.scale(s,1);
c.fillStyle = '#DFDF00';
c.strokeStyle = '#FFFF00';
if (g) {
c.fillStyle = '#AAAAAA';
c.strokeStyle = '#DDDDDD';
}
c.lineWidth = 3;
c.beginPath();
c.arc(0, 0, r, 0, 2*Math.PI);
c.fill();
c.beginPath();
c.arc(0, 0, r, 0, 2*Math.PI);
c.stroke();
c.scale(1/s,1);
c.translate(-x, -y);
};
draw = (coins) => {
c.fillStyle = 'black';
c.fillRect(0, 0, a.width, a.height);
for (i = 0; i < coins.length; i++) {
m = coins[i];
drawCoin(m.x, m.y, m.t, m.g);
m.t += 0.1;
m.y += 5;
if (m.y > a.height) {
coins.splice(i, 1);
}
}
if (coins.length < MAX && Math.random() < 0.2) {
coins.push({
x: Math.floor(Math.random() * (a.width - (r + 5))) + r + 5,
y: r + 5,
t: 10,
g: Math.random() < 0.1
});
}
requestAnimationFrame(() => {draw(coins)});
};
coins = []
draw(coins);