From 4a810f8845fd906efec28fd38b8e0880b8738070 Mon Sep 17 00:00:00 2001 From: TheJoeCoder <joe@radialbog9.uk> Date: Sun, 7 Jul 2024 10:19:04 +0100 Subject: [PATCH] Whitespace and comments --- public/js/background_anim.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/public/js/background_anim.js b/public/js/background_anim.js index 2d03cf1..2ad7427 100644 --- a/public/js/background_anim.js +++ b/public/js/background_anim.js @@ -251,16 +251,26 @@ window.addEventListener("mousemove", (event) => { }); window.addEventListener("resize", () => { + // Width before resize let oldWidth = canvas.width; + // Height before resize let oldHeight = canvas.height; + + // Set canvas size and display parameters setDisplayParameters(); + + // Calculate old to new width ratio let widthRatio = canvas.width / oldWidth; + // Calculate old to new height ratio let heightRatio = canvas.height / oldHeight; - // Loop all dots + + // Loop through all dots for (let i = 0; i < dots.length; i++) { let dot = dots[i]; + // Reset radius of dots dot.radius = randInt(RADIUS_MIN, RADIUS_MAX); + // Reset dots positions outside new window if the window has gotten smaller dot.x = dot.x * widthRatio; dot.y = dot.y * heightRatio; -- GitLab