Module: ColorContrastCalc::Converter::Invert
- Defined in:
- lib/color_contrast_calc/converter.rb
Class Method Summary collapse
-
.calc_rgb(rgb, ratio) ⇒ Array<Integer>
Return an inverted RGB value of passed color.
Class Method Details
.calc_rgb(rgb, ratio) ⇒ Array<Integer>
Return an inverted RGB value of passed color.
The calculation is based on the definition found at www.w3.org/TR/filter-effects/#funcdef-invert www.w3.org/TR/filter-effects-1/#invertEquivalent www.w3.org/TR/SVG/filters.html#TransferFunctionElementAttributes
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 |