diff -u b/core/modules/color/color.module b/core/modules/color/color.module --- b/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -292,43 +292,39 @@ } } - //Checks to see if text is readable on white background + // Checks to see if text is readable on white background. $test = _color_luminositytest('#fff', $palette['text']); if ($test <= 7) { - drupal_set_message(t("The selected text color, when used with a white background, - has a luminosity ratio of %result. The W3C WCAG 2.0 accessibility standard - suggests this ratio must be a minimum of 4.5 and optimally at least 7.0 for - the text to be readable by all.", + drupal_set_message(t("The selected text color, when used with a white background, has a luminosity ratio of %result. The W3C WCAG 2.0 accessibility standard suggests this ratio must be a minimum of 4.5 and optimally at least 7.0 for the text to be readable by all.", array('%result' => $test)), $test >= 4.5 ? 'status': 'warning'); } - //Checks to see if links are readable on white background + // Checks to see if links are readable on white background. $test = _color_luminositytest('#fff', $palette['link']); if ($test <= 7) { - drupal_set_message(t("The selected link color, when used with a white background, - has a luminosity ratio of %result. The W3C WCAG 2.0 accessibility standard - suggests this ratio must be a minimum of 4.5 and optimally at least 7.0 for - the links to be readable by all.", + drupal_set_message(t("The selected link color, when used with a white background, has a luminosity ratio of %result. The W3C WCAG 2.0 accessibility standard suggests this ratio must be a minimum of 4.5 and optimally at least 7.0 for the links to be readable by all.", array('%result' => $test)), $test >= 4.5 ? 'status': 'warning'); } } /** - * Calculate luminosity ratio, should be higher than 4.5 to meet with WCAG 2.0 color contrast standard - http://www.w3.org/TR/WCAG20/ + * Calculate luminosity ratio, should be higher than 4.5 to meet with WCAG 2.0 + * color contrast standard - http://www.w3.org/TR/WCAG20/ */ function _color_luminositytest($color1, $color2) { $color1 = _color_unpack($color1); $color2 = _color_unpack($color2); - //PHP Algorithm from http://www.splitbrain.org/blog/2008-09/18-calculating_color_contrast_with_php + // PHP Algorithm from + // http://splitbrain.org/blog/2008-09/18-calculating_color_contrast_with_php $luminosity1 = 0.2126 * pow($color1[0]/255, 2.2) + - 0.7152 * pow($color1[1]/255, 2.2) + - 0.0722 * pow($color1[2]/255, 2.2); + 0.7152 * pow($color1[1]/255, 2.2) + + 0.0722 * pow($color1[2]/255, 2.2); $luminosity2 = 0.2126 * pow($color2[0]/255, 2.2) + - 0.7152 * pow($color2[1]/255, 2.2) + - 0.0722 * pow($color2[2]/255, 2.2); + 0.7152 * pow($color2[1]/255, 2.2) + + 0.0722 * pow($color2[2]/255, 2.2); if ($luminosity1 > $luminosity2) { return round(($luminosity1 + 0.05) / ($luminosity2 + 0.05), 1);