Skip to content

Commit ca47442

Browse files
Add source for luminance calculation
1 parent 6bcd663 commit ca47442

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

webapp/src/Twig/TwigExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ private function hexToForegroundAndBorder(string $rgb): array
11651165
[$r, $g, $b] = $background;
11661166

11671167
// Calculate relative luminance
1168+
// Source: https://www.w3.org/WAI/GL/wiki/Relative_luminance
11681169
$r = ($r / 255 <= 0.03928) ? ($r / 255) / 12.92 : pow(($r / 255 + 0.055) / 1.055, 2.4);
11691170
$g = ($g / 255 <= 0.03928) ? ($g / 255) / 12.92 : pow(($g / 255 + 0.055) / 1.055, 2.4);
11701171
$b = ($b / 255 <= 0.03928) ? ($b / 255) / 12.92 : pow(($b / 255 + 0.055) / 1.055, 2.4);

0 commit comments

Comments
 (0)