Class: Colorspace::CIELABColor
- Inherits:
-
Object
- Object
- Colorspace::CIELABColor
- Defined in:
- lib/colorspace/colorlib.rb
Overview
A color in the CIE LAB color space.
Class Method Summary collapse
Instance Method Summary collapse
-
#cie76(other) ⇒ Object
rubocop: enable Metrics/AbcSize.
- #ciede2000(other) ⇒ Object
- #to_a ⇒ Object
- #to_ary ⇒ Object
- #to_hex ⇒ Object
-
#to_xyz(illuminant: D65) ⇒ Object
rubocop: disable Metrics/AbcSize.
Class Method Details
Instance Method Details
#cie76(other) ⇒ Object
rubocop: enable Metrics/AbcSize
163 164 165 |
# File 'lib/colorspace/colorlib.rb', line 163 def cie76(other) (((other.l - l)**2) + ((other.a - a)**2) + ((other.b - b)**2))**0.5 end |
#ciede2000(other) ⇒ Object
167 168 169 170 |
# File 'lib/colorspace/colorlib.rb', line 167 def ciede2000(other) # TODO: write this cie76(other) end |
#to_a ⇒ Object
173 |
# File 'lib/colorspace/colorlib.rb', line 173 def to_a = to_ary |
#to_ary ⇒ Object
172 |
# File 'lib/colorspace/colorlib.rb', line 172 def to_ary = [l, a, b] |
#to_hex ⇒ Object
145 146 147 |
# File 'lib/colorspace/colorlib.rb', line 145 def to_hex to_xyz.to_srgb.to_hex end |
#to_xyz(illuminant: D65) ⇒ Object
rubocop: disable Metrics/AbcSize
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/colorspace/colorlib.rb', line 150 def to_xyz(illuminant: D65) xn, yn, zn = illuminant.x, illuminant.y, illuminant.z p = (l + 16) / 116.0 x = xn * ((p + (a / 500.0))**3) / 100.0 y = yn * (p**3) / 100.0 z = zn * ((p - (b / 200.0))**3) / 100.0 XYZTristimulus.new(x:, y:, z:) end |