Skip to content

Instantly share code, notes, and snippets.

@nblackburn nblackburn/luminence.js
Last active May 29, 2019

Embed
What would you like to do?
module.exports = (red, green, blue) => {
const rs = red / 255;
const gs = green / 255;
const bs = blue / 255;
const rn = rs <= 0.03928 ? rs / 12.92 : Math.pow((rs + 0.055) / 1.055, 2.4);
const gn = gs <= 0.03928 ? gs / 12.92 : Math.pow((gs + 0.055) / 1.055, 2.4);
const bn = bs <= 0.03928 ? bs / 12.92 : Math.pow((bs + 0.055) / 1.055, 2.4);
return (0.2126 * rn) + (0.7152 * gn) + (0.0722 * bn);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.