Module: ColorContrastCalc::Converter::Invert

Defined in:
lib/color_contrast_calc/converter.rb

Class Method Summary collapse

Class Method Details

.calc_rgb(rgb, ratio) ⇒ Array<Integer>

Parameters:

  • rgb (Array<Integer>)

    The Original RGB value before the inversion

  • ratio (Float)

    Proportion of the conversion in percentage

Returns:

  • (Array<Integer>)

    Inverted RGB value



78
79
80
81
# File 'lib/color_contrast_calc/converter.rb', line 78

def self.calc_rgb(rgb, ratio)
  r = ratio.to_f
  rgb.map {|c| ((100 * c - 2 * c * r + 255 * r) / 100).round }
end