samedi 19 août 2023

Javascript: Inverting randomly generated colors

I'm making a random color generator and want it to give me multiple colors coresponding to other color theories, and am so far struggling with getting a complementary color, i've tried a few ways to invert it and have either put it in wrong, or it just did not work all together.

Here's one of the color generators, only diffrence from this one is a sleep() function i put in and the rest are numbered.

function Color(){
    var bg_colour = Math.floor(Math.random() * 16777215).toString(16);
    bg_colour = "#" + ("000000" + bg_colour).slice(-6);
    document.getElementById("displayColor").innerHTML = bg_colour;
    document.getElementById("displayColor").style.color = bg_colour;
}

Here is one of the others just incase it is important.

function Color2(){
    sleep(100)
        var bg_colour2 = Math.floor(Math.random() * 16777215).toString(16);
        bg_colour2 = "#" + ("000000" + bg_colour2).slice(-6);
        document.getElementById("displayColor2").innerHTML = bg_colour2;
        document.getElementById("displayColor2").style.color = bg_colour2;
    sleep(30)
}

Thanks in advance, i'll continue working on it in my free time and post any updates on if i found out something or if someone else did.




Aucun commentaire:

Enregistrer un commentaire