Class: ColourConverter::ColourChanel

Inherits:
Object
  • Object
show all
Defined in:
lib/colour_helper.rb

Overview

An individual colour chanel, eg. red, green or blue

Instance Method Summary collapse

Constructor Details

#initialize(hex_value) ⇒ ColourChanel

Returns a new instance of ColourChanel.



28
29
30
# File 'lib/colour_helper.rb', line 28

def initialize(hex_value)
  @value = hex_value.hex / 255.0
end

Instance Method Details

#luminanceObject



32
33
34
# File 'lib/colour_helper.rb', line 32

def luminance
  @value <= 0.03928 ? @value / 12.92 : ((@value + 0.055) / 1.055)**2.4
end