Skip to content

Instantly share code, notes, and snippets.

@hail2u
Created October 21, 2015 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hail2u/a2b3c30344a97e8fdcb9 to your computer and use it in GitHub Desktop.
Save hail2u/a2b3c30344a97e8fdcb9 to your computer and use it in GitHub Desktop.
rgb()を渡すと0から255で明度を返す関数
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