Class: Gauguin::ColorSpace::RgbVector

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

Constant Summary collapse

MAX_VAUE =
255.0
RGB_TO_XYZ =

Observer. = 2°, Illuminant = D65

Matrix[[0.4124, 0.2126, 0.0193]

Instance Method Summary collapse

Instance Method Details

#pivot!Object



11
12
13
14
15
16
# File 'lib/gauguin/color_space/rgb_vector.rb', line 11

def pivot!
  self.each.with_index do |component, i|
    self[i] = pivot(component / MAX_VAUE)
  end
  self
end

#to_xyzObject



18
19
20
21
22
# File 'lib/gauguin/color_space/rgb_vector.rb', line 18

def to_xyz
  self.pivot!
  matrix = Matrix[self] * RGB_TO_XYZ
  XyzVector[*matrix.row_vectors.first.to_a]
end