From what I understand you can get the complimentary color of a given hex color by subtracting the known color from white (#FFFFFF). In my case, the known color is one that I am randomly generating using the following code:
var randomColor = "#000000".replace(/0/g,function(){
return (~~(Math.random()*16)).toString(16);});
And I basically want to do this:
function compColor(randomColor){
return 0xFFFFFF - randomColor;
}
I have this random hex number but I'm unable to subtract it from a decimal. Will I have to convert from hex to decimal and back to hex again to get the complimentary color I'm looking for? It seems like this is not the most efficient way to do this.
Aucun commentaire:
Enregistrer un commentaire