Module: ColorContrastCalc::Converter::Brightness

Defined in:
lib/color_contrast_calc/converter.rb

Class Method Summary collapse

Class Method Details

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

Return brightness adjusted RGB value of passed color.

The calculation is based on the definition found at www.w3.org/TR/filter-effects/#funcdef-brightness www.w3.org/TR/SVG/filters.html#TransferFunctionElementAttributes

Parameters:

  • rgb (Array<Integer>)

    The Original RGB value before the adjustment

  • ratio (Float) (defaults to: 100)

    Adjustment ratio in percentage

Returns:

  • (Array<Integer>)

    Brightness adjusted RGB value



112
113
114
115
# File 'lib/color_contrast_calc/converter.rb', line 112

def self.calc_rgb(rgb, ratio = 100)
  r = ratio.to_f
  Converter.rgb_map(rgb) {|c| c * r / 100 }
end