Class: Colorspace::XYZTristimulus
- Inherits:
-
Object
- Object
- Colorspace::XYZTristimulus
- Defined in:
- lib/colorspace/colorlib.rb
Overview
A tristimulus value in the CIE 1931 space.
Instance Method Summary collapse
- #to_a ⇒ Object
-
#to_ary ⇒ Object
rubocop: enable Metrics/AbcSize.
-
#to_cielab(illuminant: D65) ⇒ Object
rubocop: disable Metrics/AbcSize.
- #to_srgb ⇒ Object
- #to_srgb_linear ⇒ Object
Instance Method Details
#to_a ⇒ Object
63 |
# File 'lib/colorspace/colorlib.rb', line 63 def to_a = to_ary |
#to_ary ⇒ Object
rubocop: enable Metrics/AbcSize
62 |
# File 'lib/colorspace/colorlib.rb', line 62 def to_ary = [x, y, z] |
#to_cielab(illuminant: D65) ⇒ Object
rubocop: disable Metrics/AbcSize
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/colorspace/colorlib.rb', line 50 def to_cielab(illuminant: D65) x_, y_, z_ = x * 100, y * 100, z * 100 xn, yn, zn = illuminant.x, illuminant.y, illuminant.z l = (116 * scale_f(y_ / yn)) - 16 a = 500 * (scale_f(x_ / xn) - scale_f(y_ / yn)) b = 200 * (scale_f(y_ / yn) - scale_f(z_ / zn)) CIELABColor.new(l:, a:, b:) end |
#to_srgb ⇒ Object
34 35 36 |
# File 'lib/colorspace/colorlib.rb', line 34 def to_srgb to_srgb_linear.gamma_compress end |
#to_srgb_linear ⇒ Object
28 29 30 31 32 |
# File 'lib/colorspace/colorlib.rb', line 28 def to_srgb_linear r, g, b = (XYZ_RGB_MATRIX * Matrix[[x], [y], [z]]).to_a.flatten SRGBLinearColor.new(r:, g:, b:) end |