Skip to content

Commit

Permalink
Merge branch 'pr/127'
Browse files Browse the repository at this point in the history
  • Loading branch information
sk66641 committed Jun 2, 2024
2 parents b9d691d + f0edcda commit a784d41
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ <h1 id="changingHeading" style="font-family: Arial, sans-serif; font-size: 39px;
<option value="conic">Conic</option>
<option value="linear">Linear</option>
<option value="radial">Radial</option>
<option value="custom">Custom Pattern</option>
</select>
</div>
<div>
Expand Down
27 changes: 26 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a784d41

Please sign in to comment.