From cdd86a8fbe87c73ab29383e6eec79043843e3cea Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Sun, 21 Oct 2018 18:52:26 +0200 Subject: [PATCH] Add comments to magic values --- lib/tasks/sprites.thor | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/tasks/sprites.thor b/lib/tasks/sprites.thor index 64dd82b4..bd2ff781 100644 --- a/lib/tasks/sprites.thor +++ b/lib/tasks/sprites.thor @@ -105,6 +105,8 @@ class SpritesCLI < Thor end def get_contrast(base, other) + # Calculating the contrast ratio as described in the WCAG 2.0: + # https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef l1 = get_luminance(base) + 0.05 l2 = get_luminance(other) + 0.05 ratio = l1 / l2 @@ -118,6 +120,9 @@ class SpritesCLI < Thor ChunkyPNG::Color.b(color).to_f ] + # Calculating the relative luminance as described in the WCAG 2.0: + # https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef + rgb.map! do |value| value /= 255 value < 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4