My last note to Bob had an echo function in it, and it reminded me that I’ve
been meaning to point this article out to users. If you have a Jmol app where
users can change background color, here is an article that describes a simple
JavaScript function that selects between black or white as the best screen
contrast color (for echo):
https://24ways.org/2010/calculating-color-contrast/
<https://24ways.org/2010/calculating-color-contrast/>
Here’s the function:
function getContrastYIQ(hexcolor){
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) ? 'black' : 'white';
}
If you’re like me and never heard of YIQ:
https://en.wikipedia.org/wiki/YIQ <https://en.wikipedia.org/wiki/YIQ>
Otis
--
Otis Rothenberger
o...@chemagic.org
http://chemagic.org
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users