randomstringtocsscolor icon indicating copy to clipboard operation
randomstringtocsscolor copied to clipboard

Text colour is invisible on light pages

Open Haroenv opened this issue 10 years ago • 0 comments

// 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

Haroenv avatar Jan 04 '16 12:01 Haroenv