()
| 33 | |
| 34 | // animating the ball generation process |
| 35 | function animationLoop() { |
| 36 | ctx.clearRect(0, 0, w, h); |
| 37 | if (mouse.x !== undefined && mouse.y !== undefined) { |
| 38 | balls.push(new Ball()); |
| 39 | } |
| 40 | if (balls.length > 200) { |
| 41 | balls = balls.slice(1); |
| 42 | } |
| 43 | drawBalls(); |
| 44 | requestAnimationFrame(animationLoop); |
| 45 | } |
| 46 | |
| 47 | // function to show balls on canvas |
| 48 | function drawBalls() { |