summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/rbg.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/js/rbg.js b/src/js/rbg.js
index 0b1cec5f..40f0dadd 100644
--- a/src/js/rbg.js
+++ b/src/js/rbg.js
@@ -1,3 +1,5 @@
+document.body.style.transition = "background 1s ease-in-out";
+
function getRandomColor() {
const letters = "0123456789ABCDEF";
let color = "#";
@@ -8,17 +10,32 @@ function getRandomColor() {
}
function setRandomGradient() {
- const rand3 = Math.floor(Math.random());
+ const rand3 = Math.floor(Math.random() * 3) + 1;
if (rand3 === 1) {
- document.body.style.background = `linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
+ document.body.style.background = `linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
} else if (rand3 === 2) {
- document.body.style.background = `linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
-linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
+ document.body.style.background = `linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
+linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
} else {
- document.body.style.background = `linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
-linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
-linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
+ document.body.style.background = `linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
+linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}),
+linear-gradient(${Math.floor(
+ Math.random() * 180
+ )}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`;
}
}
setRandomGradient();
+
+// Execute setRandomGradient() every 1 minute
+setInterval(setRandomGradient, 60000);