Last active
May 29, 2019 18:20
-
-
Save nblackburn/05d151774f6a29fc5528169d101ea1d5 to your computer and use it in GitHub Desktop.
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
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