Created
January 5, 2020 14:01
-
-
Save ssaurel/9b97fe2bd683e625bc60f4d0db027885 to your computer and use it in GitHub Desktop.
hexislight function for the Hexadecimal Color Clock on the SSaurel's Blog
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
function hexislight(color) { | |
var hex = color.replace('#', ''); | |
var red = parseInt(hex.substr(0, 2), 16); | |
var green = parseInt(hex.substr(2, 2), 16); | |
var blue = parseInt(hex.substr(4, 2), 16); | |
// it is a known formula, nothing magical here | |
var brightness = ((red * 299) + (green * 587) + (blue * 114)) / 1000; | |
return brightness > 155; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment