From 7c4b742eb165681a10c6153d0e5da239a555c23a Mon Sep 17 00:00:00 2001 From: sidharth2829 <111569459+sidharth2829@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:27:41 +0530 Subject: [PATCH] Fixes #74 --- index.html | 1 + script.js | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 13fd70d..12a4c42 100644 --- a/index.html +++ b/index.html @@ -87,6 +87,7 @@

Conic +
diff --git a/script.js b/script.js index 87a6728..84bb7d0 100644 --- a/script.js +++ b/script.js @@ -131,7 +131,32 @@ document.addEventListener('DOMContentLoaded', () => { return colors; } - if (n == 1) { + function createRandomGradientPattern(n) { + let gradientPattern = `background-color: ${getRandomColorBetween(rgbColor1, rgbColor2)}; background-image: `; + + for (let i = 0; i < n; i++) { + const randomPositionX = Math.floor(Math.random() * 100); + const randomPositionY = Math.floor(Math.random() * 100); + gradientPattern += `radial-gradient(circle at ${randomPositionX}% ${randomPositionY}%, ${getRandomColorBetween(rgbColor1, rgbColor2)} 0%, transparent 50%), `; + } + + // Remove the last comma and space + gradientPattern = gradientPattern.slice(0, -2); + gradientPattern += '; background-blend-mode: normal;'; + + return gradientPattern; + } + + function applyRandomGradientPattern() { + document.body.style.cssText = createRandomGradientPattern(n); + } + + if (view === "custom") { + applyRandomGradientPattern(); + setInterval(() => { + applyRandomGradientPattern(); + }, set_time); + } else if (n == 1) { document.body.style.backgroundColor = getRandomColorBetween(rgbColor1, rgbColor2); setInterval(() => { document.body.style.backgroundColor = getRandomColorBetween(rgbColor1, rgbColor2);