INNER CODE UNIT · JavaScript

loop

slashhuang/blog · essays/tutorial/jrg_1_OOP/canvas/main.js:50

function loop() {
  ctx.fillStyle = 'rgba(0, 0, 0, 0.25)';
  ctx.fillRect(0, 0, width, height);
  while (balls.length < 25) {
    var ball = new Ball();
    balls.push(ball);
  }

  for (var i = 0; i < balls.length; i++) {
    balls[i].draw();
    balls[i].update();
  }
  requestAnimationFrame(loop);
}
loop();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…