Skip to content

Instantly share code, notes, and snippets.

@anuraghazra
Last active May 16, 2019 14:24
Show Gist options
  • Save anuraghazra/41c19a0b13ee02f5a8b2607ab4dd893b to your computer and use it in GitHub Desktop.
Save anuraghazra/41c19a0b13ee02f5a8b2607ab4dd893b to your computer and use it in GitHub Desktop.
let canvas = document.getElementById("c");
let ctx = canvas.getContext("2d");
let CANVAS_WIDTH = window.innerWidth;
let CANVAS_HEIGHT = window.innerHeight;
canvas.width = CANVAS_WIDTH;
canvas.height = CANVAS_HEIGHT;
let dots = [];
for (let i = 0; i < 50; i++) {
dots.push(new Dot(Math.random() * CANVAS_WIDTH, Math.random() * CANVAS_HEIGHT));
}
function animate() {
ctx.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
for (let d of dots) {
d.update();
d.constrain();
d.render(ctx);
}
requestAnimationFrame(animate);
}
animate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment