Created
September 29, 2014 09:16
-
-
Save DavideMontersino/ffad0ae130db5f82e19f to your computer and use it in GitHub Desktop.
This file contains 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
// From http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx | |
// returns a number in the rage of 0 (black) to 255 (White) and to set the foreground color based on the Brightness method | |
// c is an array where 0 is red, 1 is green, 2 is blue | |
//rgb values are on a 0 - 255 scale | |
var colorBrightness = function(c){ | |
return Math.sqrt( | |
c[0] * c[0] * .241 + | |
c[1] * c[1] * .691 + | |
c[2] * c[2] * .068); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment