History

Add comments to magic values

Jasper van Merle committed 8 years ago

Commit cdd86a81 parent 9551fbc1 file · +5 −0Browse files

Unified · Split

lib/tasks/sprites.thor+5−0
@@ -105,6 +105,8 @@ class SpritesCLI < Thor · 104 unmodified lines
105 end105 end
106 106
107 def get_contrast(base, other)107 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
108 l1 = get_luminance(base) + 0.05110 l1 = get_luminance(base) + 0.05
109 l2 = get_luminance(other) + 0.05111 l2 = get_luminance(other) + 0.05
110 ratio = l1 / l2112 ratio = l1 / l2
@@ -118,6 +120,9 @@ class SpritesCLI < Thor · 7 unmodified lines
118 ChunkyPNG::Color.b(color).to_f120 ChunkyPNG::Color.b(color).to_f
119 ]121 ]
120 122
123 # Calculating the relative luminance as described in the WCAG 2.0:
124 # https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
125
121 rgb.map! do |value|126 rgb.map! do |value|
122 value /= 255127 value /= 255
123 value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4128 value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4