Skip to content

Instantly share code, notes, and snippets.

@ncou
Forked from jfsiii/relativelumance.js
Created November 6, 2016 10:50
Show Gist options
  • Select an option

  • Save ncou/0845aec4928c84e4ff6485174c037757 to your computer and use it in GitHub Desktop.

Select an option

Save ncou/0845aec4928c84e4ff6485174c037757 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