diff options
| author | Volpeon <git@volpeon.ink> | 2021-12-25 11:23:29 +0100 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2021-12-25 11:23:29 +0100 |
| commit | 0ee5cb9146659c9255bf56367330a9a7828b8b49 (patch) | |
| tree | 527579595f4ca74a585e9bc2d14d7952f149a5a4 /content | |
| parent | Snow improvements (diff) | |
| download | volpeon.ink-0ee5cb9146659c9255bf56367330a9a7828b8b49.tar.gz volpeon.ink-0ee5cb9146659c9255bf56367330a9a7828b8b49.tar.bz2 volpeon.ink-0ee5cb9146659c9255bf56367330a9a7828b8b49.zip | |
Better snowflake severity algorithm
Diffstat (limited to 'content')
| -rw-r--r-- | content/script.js | 15 |
1 files 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 @@ | |||
| 1 | let i = 0; | ||
| 2 | |||
| 3 | function createSnowFlake() { | 1 | function createSnowFlake() { |
| 4 | const threshold = -10 * Math.log10(window.innerWidth / 1000); | ||
| 5 | |||
| 6 | if (++i < threshold) { | ||
| 7 | return; | ||
| 8 | } | ||
| 9 | |||
| 10 | i = 0; | ||
| 11 | |||
| 12 | const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg"); | 2 | const snowFlake = document.createElementNS("http://www.w3.org/2000/svg", "svg"); |
| 13 | const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use"); | 3 | const snowFlakeInner = document.createElementNS("http://www.w3.org/2000/svg", "use"); |
| 14 | 4 | ||
| @@ -27,7 +17,8 @@ function createSnowFlake() { | |||
| 27 | snowFlake.appendChild(snowFlakeInner); | 17 | snowFlake.appendChild(snowFlakeInner); |
| 28 | document.body.appendChild(snowFlake); | 18 | document.body.appendChild(snowFlake); |
| 29 | 19 | ||
| 30 | setTimeout(() => { snowFlake.remove(); }, aniDuration); | 20 | setTimeout(() => snowFlake.remove(), aniDuration); |
| 21 | setTimeout(() => createSnowFlake(), 50 / Math.log10(window.innerWidth / 1000 + 1)); | ||
| 31 | } | 22 | } |
| 32 | 23 | ||
| 33 | setInterval(createSnowFlake, 100); | 24 | createSnowFlake(); |
