Module: ColorContrastCalc::Converter::Contrast
- Defined in:
- lib/color_contrast_calc/converter.rb
Class Method Summary collapse
-
.calc_rgb(rgb, ratio = 100) ⇒ Array<Integer>
Return contrast adjusted RGB value of passed color.
Class Method Details
.calc_rgb(rgb, ratio = 100) ⇒ Array<Integer>
Return contrast adjusted RGB value of passed color.
The calculation is based on the definition found at www.w3.org/TR/filter-effects/#funcdef-contrast www.w3.org/TR/SVG/filters.html#TransferFunctionElementAttributes
43 44 45 46 |
# File 'lib/color_contrast_calc/converter.rb', line 43 def self.calc_rgb(rgb, ratio = 100) r = ratio.to_f Converter.rgb_map(rgb) {|c| (c * r + 255 * (50 - r / 2)) / 100 } end |