From 0ee5cb9146659c9255bf56367330a9a7828b8b49 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 25 Dec 2021 11:23:29 +0100 Subject: Better snowflake severity algorithm --- content/script.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/content/script.js b/content/script.js index b972200..78b18b0 100644 --- a/content/script.js +++ b/content/script.js @@ -1,14 +1,4 @@ -let i = 0; - function createSnowFlake() { - const threshold = -10 * Math.log10(window.innerWidth / 1000); - - if (++i < threshold) { - return; - } - - i = 0; - const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg"); const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use"); @@ -27,7 +17,8 @@ function createSnowFlake() { snowFlake.appendChild(snowFlakeInner); document.body.appendChild(snowFlake); - setTimeout(() => { snowFlake.remove(); }, aniDuration); + setTimeout(() => snowFlake.remove(), aniDuration); + setTimeout(() => createSnowFlake(), 50 / Math.log10(window.innerWidth / 1000 + 1)); } -setInterval(createSnowFlake, 100); +createSnowFlake(); -- cgit v1.2.3-54-g00ecf