Last active
May 16, 2019 14:24
-
-
Save anuraghazra/41c19a0b13ee02f5a8b2607ab4dd893b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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