import parseToRgba from './parseToRgba' ; /**
 * Returns a number (float) representing the luminance of a color.
 */ function getLuminance ( color ) { if ( color === 'transparent' ) return 0 ; function f ( x ) { const channel = x / 255 ; return channel <= 0.03928 ? channel / 12.92 : Math . pow ( ( ( channel + 0.055 ) / 1.055 ) , 2.4 ) ; } const [ r , g , b ] = parseToRgba ( color ) ; return 0.2126 * f ( r ) + 0.7152 * f ( g ) + 0.0722 * f ( b ) ; } export default getLuminance ;