Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Last active March 28, 2022 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jfsiii/7234419 to your computer and use it in GitHub Desktop.
Save jfsiii/7234419 to your computer and use it in GitHub Desktop.
Relative Luminance from RGB color.
// from http://en.wikipedia.org/wiki/Luminance_(relative)
// R, G, B are integers between 0 and 255
function relativeLuminance(R, G, B) {
var Y = (0.2126 * R + 0.7152 * G + 0.0722 * B) / 255;
return Y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment