Keys →
Functions ↓
function colorContrastRatio ( $c1, $c2 ) {#-k color#- Calculate contrast ratio acording to WCAG 2.0 formula#-p $c1 - req - Hex RGB color (Must be in the form #hhhhhh)#-p $c2 - req - Hex RGB color (Must be in the form #hhhhhh)#-p - ret - (float) value between 1 (no contrast) and 21 (max contrast)#- @link http://www.w3.org/TR/WCAG20/#contrast-ratiodef#-c author Marcus Bointon <marcus@synchromedia.co.uk>#-d 2/19/21 - Added $y1 = colorRelativeLuminance ( $c1 ); $y2 = colorRelativeLuminance ( $c2 );# Arrange so $y1 is lightest if ($y1 < $y2) { $y3 = $y1; $y1 = $y2; $y2 = $y3; } return ($y1 + 0.05) / ($y2 + 0.05); }?>