diff --git a/lib/term/ansicolor/hsl_triple.rb b/lib/term/ansicolor/hsl_triple.rb index 3babaa7..ccd93cc 100644 --- a/lib/term/ansicolor/hsl_triple.rb +++ b/lib/term/ansicolor/hsl_triple.rb @@ -2,7 +2,7 @@ module Term module ANSIColor class HSLTriple def self.from_rgb_triple(rgb) - ps = rgb.to_a.map { |x| x / 255.0 } + ps = [ rgb.red / 255.0, rgb.green / 255.0, rgb.blue / 255.0 ] p_min = ps.min p_max = ps.max p_red, p_green, p_blue = ps diff --git a/lib/term/ansicolor/rgb_color_metrics.rb b/lib/term/ansicolor/rgb_color_metrics.rb index f297de0..7c789bc 100644 --- a/lib/term/ansicolor/rgb_color_metrics.rb +++ b/lib/term/ansicolor/rgb_color_metrics.rb @@ -19,16 +19,16 @@ def normalize(v) if v <= 0.04045 v / 12 else - ( (v + 0.055) / 1.055) ** 2.4 + ( (v + 0.055) / 1.055 ) ** 2.4 end end def normalize_rgb_triple(rgb_triple) [ - rgb_triple.red, - rgb_triple.green, - rgb_triple.blue - ].map { |v| normalize(v) } + normalize(rgb_triple.red), + normalize(rgb_triple.green), + normalize(rgb_triple.blue), + ] end end end diff --git a/lib/term/ansicolor/rgb_triple.rb b/lib/term/ansicolor/rgb_triple.rb index e5c63d5..12d6c24 100644 --- a/lib/term/ansicolor/rgb_triple.rb +++ b/lib/term/ansicolor/rgb_triple.rb @@ -59,7 +59,11 @@ def self.[](thing) end def initialize(red, green, blue) - @values = [ red, green, blue ].map! { |v| v.clamp(0, 0xff) } + @values = [ + red.clamp(0, 0xff), + green.clamp(0, 0xff), + blue.clamp(0, 0xff), + ] end def red @@ -106,7 +110,7 @@ def html def css(percentage: false) if percentage - "rgb(%s%%,%s%%,%s%%)" % @values.map { |v| 100.0 * v / 255 } + "rgb(%s%%,%s%%,%s%%)" % percentages else "rgb(%u,%u,%u)" % @values end