Skip to content

Commit cdd86a8

Browse files
committed
Add comments to magic values
1 parent 9551fbc commit cdd86a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/tasks/sprites.thor

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class SpritesCLI < Thor
105105
end
106106

107107
def get_contrast(base, other)
108+
# Calculating the contrast ratio as described in the WCAG 2.0:
109+
# https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
108110
l1 = get_luminance(base) + 0.05
109111
l2 = get_luminance(other) + 0.05
110112
ratio = l1 / l2
@@ -118,6 +120,9 @@ class SpritesCLI < Thor
118120
ChunkyPNG::Color.b(color).to_f
119121
]
120122

123+
# Calculating the relative luminance as described in the WCAG 2.0:
124+
# https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
125+
121126
rgb.map! do |value|
122127
value /= 255
123128
value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4

0 commit comments

Comments
 (0)