Class: Abachrome::Converters::SrgbToLms

Inherits:
Base
  • Object
show all
Defined in:
lib/abachrome/converters/srgb_to_lms.rb

Instance Attribute Summary

Attributes inherited from Base

#from_space, #to_space

Class Method Summary collapse

Methods inherited from Base

#can_convert?, #convert, find_converter, #initialize, raise_unless, register

Constructor Details

This class inherits a constructor from Abachrome::Converters::Base

Class Method Details

.convert(srgb_color) ⇒ Abachrome::Color

Converts a color from sRGB color space to LMS color space.

This method converts sRGB to linear RGB first, then to LMS cone response space. The LMS color space represents the response of the three types of cone cells in the human eye (Long, Medium, Short wavelength sensitivity).

the same alpha as the input color

Parameters:

Returns:

Raises:

  • (ArgumentError)

    If the input color is not in sRGB color space



16
17
18
19
20
21
22
23
24
# File 'lib/abachrome/converters/srgb_to_lms.rb', line 16

def self.convert(srgb_color)
  raise_unless srgb_color, :srgb

  # Convert sRGB to linear RGB first
  lrgb_color = Converters::SrgbToLrgb.convert(srgb_color)

  # Then convert linear RGB to LMS
  Converters::LrgbToLms.convert(lrgb_color)
end