Class: ColourConverter::ColourChanel
- Inherits:
-
Object
- Object
- ColourConverter::ColourChanel
- Defined in:
- lib/colour_helper.rb
Overview
An individual colour chanel, eg. red, green or blue
Instance Method Summary collapse
-
#initialize(hex_value) ⇒ ColourChanel
constructor
A new instance of ColourChanel.
- #luminance ⇒ Object
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
#luminance ⇒ Object
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 |