Class: Gauguin::ColorSpace::XyzVector

Inherits:
Vector
  • Object
show all
Defined in:
lib/gauguin/color_space/xyz_vector.rb

Constant Summary collapse

WHITE_REFERENCE =
self[95.047, 100.000, 108.883]
EPSILON =
0.008856
KAPPA =
903.3

Instance Method Summary collapse

Instance Method Details

#to_labObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gauguin/color_space/xyz_vector.rb', line 9

def to_lab
  zipped = self.zip(XyzVector::WHITE_REFERENCE)
  x, y, z = zipped.map do |component, white_component|
    component / white_component
  end

  l = 116 * f(y) - 16
  a = 500 * (f(x) - f(y))
  b = 200 * (f(y) - f(z))

  LabVector[l, a, b]
end