From bb4a0fec79187ae768b1a23ad50887d736edb9ba Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 11 Oct 2023 22:58:35 +0800 Subject: more colors(3) --- src/js/rbg.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/js') diff --git a/src/js/rbg.js b/src/js/rbg.js index e67a0063..0b1cec5f 100644 --- a/src/js/rbg.js +++ b/src/js/rbg.js @@ -8,7 +8,17 @@ function getRandomColor() { } function setRandomGradient() { - document.body.style.background = `linear-gradient(${Math.floor(Math.random() * 180)}deg, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()}, ${getRandomColor()})`; + const rand3 = Math.floor(Math.random()); + if (rand3 === 1) { + 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()})`; + } 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()})`; + } } setRandomGradient(); -- cgit v1.2.3