From f115af4715d80ea4fead5a3d26b2efc018be9131 Mon Sep 17 00:00:00 2001 From: ByteDice Date: Sun, 5 Jan 2025 14:51:07 +0100 Subject: [PATCH] added onRezise event --- globalScript.js | 26 ++++++++++++++++++++++++-- index.html | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/globalScript.js b/globalScript.js index 66e0ce3..649dbd0 100644 --- a/globalScript.js +++ b/globalScript.js @@ -6,6 +6,7 @@ const PAGES = { let CURRENT_PAGE = PAGES.null let isAnimating = true +let gridVisible = false function randomFloat(min, max) { return Math.random() * (max - min) + min; @@ -32,8 +33,15 @@ function clampNearest(n, mul) { } -function showGrid() { +function toggleGrid() { + if (gridVisible) { + document.getElementById("gridCanvas").remove() + gridVisible = false + return + } + let canvasEl = document.createElement("canvas") + canvasEl.id = "gridCanvas" canvasEl.width = window.innerWidth canvasEl.height = window.innerHeight canvasEl.style.position = "absolute" @@ -62,6 +70,8 @@ function showGrid() { } ctx.stroke() + + gridVisible = true } @@ -112,4 +122,16 @@ document.addEventListener("DOMContentLoaded", async function() { else { setLoadingProgress("Cleaning up...") } -}, false) \ No newline at end of file +}, false) + + +window.addEventListener("resize", () => { + switch (CURRENT_PAGE) { + case (PAGES.SYNTHWAVE): onResizeSynthWave() + } + + if (gridVisible) { + toggleGrid() + toggleGrid() + } +}) \ No newline at end of file diff --git a/index.html b/index.html index 0b27012..a4c1956 100644 --- a/index.html +++ b/index.html @@ -61,12 +61,15 @@
+ +

Loading...
Loading files...

Tip: Tip loading...

+