default avatars do not meet ADA contrast ratios in many color combinations.
can someone help me decipher these multipliers?
where does 12.92 come from? .7152 ?
can someone help me decipher these multipliers?
where does 12.92 come from? .7152 ?
Code:
public static function getRelativeLuminance($r, $g = null, $b = null)
{
if (is_array($r))
{
$b = $r[2];
$g = $r[1];
$r = $r[0];
}
$scaler = function($color)
{
$color /= 255;
if ($color <= 0.03928)
{
return $color / 12.92;
}
else
{
return pow(($color + 0.055) / 1.055, 2.4);
}
};
$r = $scaler($r);
$g = $scaler($g);
$b = $scaler($b);
return 0.2126 * $r + 0.7152 * $g + 0.0722 * $b;
}