style: color adjustments

This commit is contained in:
Riccardo
2024-01-19 20:53:53 +01:00
parent 3af079a0f5
commit bd0b222398
7 changed files with 372 additions and 420 deletions

View File

@@ -14,7 +14,7 @@
var square = document.createElement('div');
square.style.width = size + 'px';
square.style.height = size + 'px';
square.style.backgroundColor = getRandomColor();
square.style.backgroundColor = getRandomGrey();
square.style.position = 'absolute';
square.style.left = i * (size + margin) + 'px';
square.style.top = j * (size + margin) + 'px';
@@ -23,11 +23,12 @@
}
};
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
function getRandomGrey() {
const letters = 'ABCDEF';
let color = '#';
const greyShade = Math.floor(Math.random() * 6);
for (let i = 0; i < 6; i++) {
color += letters[greyShade];
}
return color;
}