Unified · Split
| @@ -105,6 +105,8 @@ class SpritesCLI < Thor · 104 unmodified lines | ||
| 105 | 105 | end |
| 106 | 106 | |
| 107 | 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 | 110 | l1 = get_luminance(base) + 0.05 |
| 109 | 111 | l2 = get_luminance(other) + 0.05 |
| 110 | 112 | ratio = l1 / l2 |
| @@ -118,6 +120,9 @@ class SpritesCLI < Thor · 7 unmodified lines | ||
| 118 | 120 | 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 | 126 | rgb.map! do |value| |
| 122 | 127 | value /= 255 |
| 123 | 128 | value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4 |