Method: Color::Palette::MonoContrast#color_diff

Defined in:
lib/color/palette/monocontrast.rb

#color_diff(c1, c2) ⇒ Object

Returns the contrast between to colours, a decimal value between 0 and

  1. W3C accessibility guidelines for

contrast[www.w3.org/TR/AERT#color-contrast] suggest that this value be at least approximately 1.96 (500 / 255.0) for proper contrast.


158
159
160
161
162
163
# File 'lib/color/palette/monocontrast.rb', line 158

def color_diff(c1, c2)
  r = (c1.r - c2.r).abs
  g = (c1.g - c2.g).abs
  b = (c1.b - c2.b).abs
  r + g + b
end