Class: Color::CIELab
- Inherits:
-
Object
- Object
- Color::CIELab
- Defined in:
- lib/color/cie_lab.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Class Method Summary collapse
Instance Method Summary collapse
- #a ⇒ Object
- #b ⇒ Object
-
#initialize(color) ⇒ CIELab
constructor
A new instance of CIELab.
- #l ⇒ Object
- #reference_x ⇒ Object
- #reference_y ⇒ Object
- #reference_z ⇒ Object
- #to_a ⇒ Object
- #var_x ⇒ Object
- #var_y ⇒ Object
- #var_z ⇒ Object
Constructor Details
#initialize(color) ⇒ CIELab
Returns a new instance of CIELab.
10 11 12 13 14 |
# File 'lib/color/cie_lab.rb', line 10 def initialize(color) @x = color.x @y = color.y @z = color.z end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
4 5 6 |
# File 'lib/color/cie_lab.rb', line 4 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
4 5 6 |
# File 'lib/color/cie_lab.rb', line 4 def y @y end |
#z ⇒ Object (readonly)
Returns the value of attribute z.
4 5 6 |
# File 'lib/color/cie_lab.rb', line 4 def z @z end |
Class Method Details
.from_xyz(xyz_color) ⇒ Object
6 7 8 |
# File 'lib/color/cie_lab.rb', line 6 def self.from_xyz(xyz_color) self.new(xyz_color) end |
Instance Method Details
#a ⇒ Object
48 49 50 |
# File 'lib/color/cie_lab.rb', line 48 def a 500.0 * ( var_x - var_y) end |
#b ⇒ Object
52 53 54 |
# File 'lib/color/cie_lab.rb', line 52 def b 200.0 * ( var_y - var_z) end |
#l ⇒ Object
44 45 46 |
# File 'lib/color/cie_lab.rb', line 44 def l ( 116.0 * var_y) - 16.0 end |
#reference_x ⇒ Object
20 21 22 |
# File 'lib/color/cie_lab.rb', line 20 def reference_x 95.047 # Observer= 2°, Illuminant= D65 end |
#reference_y ⇒ Object
24 25 26 |
# File 'lib/color/cie_lab.rb', line 24 def reference_y 100.00 end |
#reference_z ⇒ Object
28 29 30 |
# File 'lib/color/cie_lab.rb', line 28 def reference_z 108.883 end |
#to_a ⇒ Object
16 17 18 |
# File 'lib/color/cie_lab.rb', line 16 def to_a [l, a, b] end |
#var_x ⇒ Object
32 33 34 |
# File 'lib/color/cie_lab.rb', line 32 def var_x @var_x ||= calculate_var(x / reference_x) end |
#var_y ⇒ Object
36 37 38 |
# File 'lib/color/cie_lab.rb', line 36 def var_y @var_y ||= calculate_var(y / reference_y) end |
#var_z ⇒ Object
40 41 42 |
# File 'lib/color/cie_lab.rb', line 40 def var_z @var_z ||= calculate_var(z / reference_z) end |