Created
May 8, 2013 01:56
-
-
Save thejefflarson/5537651 to your computer and use it in GitHub Desktop.
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 lum = function(hex) { | |
| var bits = hex.match(/([0-9a-f]{2})/ig).map(function(i){ | |
| var it = parseInt(i, 16) / 255; | |
| if(it < 0.03928) | |
| return it / 12.92; | |
| else | |
| return Math.pow((it + 0.055) / 1.055, 2.4); | |
| }); | |
| return 0.2126 * bits[0] + 0.7152 * bits[1] + 0.0722 * bits[2]; | |
| }; | |
| var ratioTest = function(bg, fg) { | |
| return (lum(bg) + 0.05) / (lum(fg) + 0.05) > 4.5; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment