Last active
December 25, 2015 09:39
-
-
Save akdetrick/6955652 to your computer and use it in GitHub Desktop.
converts hex to yiq color brightness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var R = parseInt(hex.substring(0,2),16), | |
| G = parseInt(hex.substring(2,4),16), | |
| B = parseInt(hex.substring(4,6),16); | |
| // luminance as weighted sum of the R, G, and B values | |
| var luma = Math.sqrt(R * R * .241 + G * G * .691 + B * B * .068); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment