Method: Inker::Color::Tools#lightness

Defined in:
lib/inker/color/tools.rb

#lightness(red, green, blue) ⇒ Float

Calculate the lightness of a color from RGB components.

Parameters:

  • red (Integer)

    the value of red component [0-255]

  • green (Integer)

    the value of green component [0-255]

  • blue (Integer)

    the value of blue component [0-255]

Returns:

  • (Float)

    a value in range 0.0-1.0 which indicates the ligthness of the color



41
42
43
44
45
# File 'lib/inker/color/tools.rb', line 41

def lightness(red, green, blue)
  min, max = [red, green, blue].minmax

  (min + max) / (2.0 * 255)
end