randomstringtocsscolor
randomstringtocsscolor copied to clipboard
Text colour is invisible on light pages
// contrast function by http://stackoverflow.com/a/11868398
function getContrastYIQ(hexcolor){
hexcolor = hexcolor.substr(1);
var r = parseInt(hexcolor.substr(0,2),16);
var g = parseInt(hexcolor.substr(2,2),16);
var b = parseInt(hexcolor.substr(4,2),16);
var yiq = ((r*299)+(g*587)+(b*114))/1000;
return (yiq >= 128) ? true : false;
}
This is what @dervondenbergen uses at demont.is