Skip to content

Commit

Permalink
Update background.js
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Jan 1, 2023
1 parent d94086b commit 1275e59
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ function animate(timeStamp) {
canvas.height = window.innerHeight;

// Calculate the elapsed time since the last frame
const elapsedTime = timeStamp - lastTime;
let elapsedTime = timeStamp - lastTime;
lastTime = timeStamp;

// If the elapsed time is too large, reset it
if (elapsedTime > 500) elapsedTime = 1;

// Clear the canvas
ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);

Expand All @@ -59,11 +62,11 @@ function animate(timeStamp) {
circles[i].r += spd * (elapsedTime / 1000);

if (circles[i].r >= 1) {
circles[i].r = circles[i].r % 1;
circles[i].x = Math.round(Math.random() * window.innerWidth);
circles[i].y = Math.round(Math.random() * window.innerHeight);
circles[i].colorRand = Math.random();
circles[i].color = minHue + Math.round(circles[i].colorRand * (maxHue - minHue));
circles[i].r = circles[i].r % 1;
circles[i].x = Math.round(Math.random() * window.innerWidth);
circles[i].y = Math.round(Math.random() * window.innerHeight);
circles[i].colorRand = Math.random();
circles[i].color = minHue + Math.round(circles[i].colorRand * (maxHue - minHue));
}

// Calculate the circle's radius
Expand Down

0 comments on commit 1275e59

Please sign in to comment.