class Gauguin::ColorSpace::RgbVector

Constants

MAX_VAUE
RGB_TO_XYZ

Observer. = 2°, Illuminant = D65

Public Instance Methods

pivot!() click to toggle source
# 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_xyz() click to toggle source
# 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

Private Instance Methods

pivot(component) click to toggle source
# File lib/gauguin/color_space/rgb_vector.rb, line 26
def pivot(component)
  component = if component > 0.04045
    ((component + 0.055) / 1.055) ** 2.4
  else
    component / 12.92
  end
  component * 100.0
end