“JS obtient une couleur hexagonale aléatoire” Réponses codées

JS Couleur hexagonale aléatoire

'#'+Math.floor(Math.random()*16777215).toString(16);
Jolly Jackal

générer un javascript de couleur RVB aléatoire

'#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6)
Bewildered Bat

JS obtient une couleur hexagonale aléatoire

"#" + ((1<<24)*Math.random() | 0).toString(16));

JS génère une couleur aléatoire

var randomColor = Math.floor(Math.random()*16777215).toString(16);
Wandering Wolf

JavaScript génère des hex

const randomHex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;

console.log(randomHex());
// Result: #92b008
Rashid Siddique

JS génère une couleur aléatoire

function get_random_color() 
{
    var color = "";
    for(var i = 0; i < 3; i++) {
        var sub = Math.floor(Math.random() * 256).toString(16);
        color += (sub.length == 1 ? "0" + sub : sub);
    }
    return "#" + color;
}

function get_rand_color()
{
    var color = Math.floor(Math.random() * Math.pow(256, 3)).toString(16);
    while(color.length < 6) {
        color = "0" + color;
    }
    return "#" + color;
}
Plain Pygmy

Réponses similaires à “JS obtient une couleur hexagonale aléatoire”

Questions similaires à “JS obtient une couleur hexagonale aléatoire”

Plus de réponses similaires à “JS obtient une couleur hexagonale aléatoire” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code