Created
October 21, 2015 11:37
-
-
Save hail2u/a2b3c30344a97e8fdcb9 to your computer and use it in GitHub Desktop.
rgb()を渡すと0から255で明度を返す関数
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 colorBrightness (color) { | |
var [c, r, g, b] = color.match(/rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/); | |
var brightness = ((r * 299) + (g * 587) + (b * 114)) / 1000; | |
return brightness; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment