Method: ColorContrastCalc::Color#complementary

Defined in:
lib/color_contrast_calc/color.rb

#complementary(name = nil) ⇒ Color

Return a complementary color of the original color.

Parameters:

  • name (String) (defaults to: nil)

    You can name the color to be created. Without this option, the value of normalized hex color code is assigned instead.

Returns:

  • (Color)

    New complementary color



348
349
350
351
# File 'lib/color_contrast_calc/color.rb', line 348

def complementary(name = nil)
  minmax = rgb.minmax.reduce {|min, max| min + max }
  self.class.new(rgb.map {|c| minmax - c }, name)
end