From 667dc0da8ae9653f93cdedea28934bdeb1624c8d Mon Sep 17 00:00:00 2001 From: ByteDice Date: Sun, 5 Jan 2025 18:22:43 +0100 Subject: [PATCH] added pixelDensity recalculation on window resize --- globalScript.js | 8 ++++++++ pxDensity.js | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/globalScript.js b/globalScript.js index 649dbd0..a6bce67 100644 --- a/globalScript.js +++ b/globalScript.js @@ -33,6 +33,11 @@ function clampNearest(n, mul) { } +function lerp(x, y, t) { + return x + t * (y - x) +} + + function toggleGrid() { if (gridVisible) { document.getElementById("gridCanvas").remove() @@ -109,6 +114,7 @@ document.addEventListener("DOMContentLoaded", async function() { setLoadingProgress("Calculating pixel density...") calcPixelDensity() + console.log("pxDensity: " + getComputedStyle(document.body).getPropertyValue("--pxDensity")) switch (CURRENT_PAGE) { case (PAGES.SYNTHWAVE): loadingScreenSynthwave() @@ -126,6 +132,8 @@ document.addEventListener("DOMContentLoaded", async function() { window.addEventListener("resize", () => { + calcPixelDensity() + switch (CURRENT_PAGE) { case (PAGES.SYNTHWAVE): onResizeSynthWave() } diff --git a/pxDensity.js b/pxDensity.js index 99f1398..67edf71 100644 --- a/pxDensity.js +++ b/pxDensity.js @@ -11,6 +11,5 @@ function calcPixelDensity() { pxDensity = parseFloat(getComputedStyle(document.body).getPropertyValue("--pxDensity")) - console.log("pxDensity: " + getComputedStyle(document.body).getPropertyValue("--pxDensity")) pxDensityDefined = true } \ No newline at end of file