Class: Abachrome::Converters::LmsToOklab

Inherits:
Base
  • Object
show all
Defined in:
lib/abachrome/converters/lms_to_oklab.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(lms_color) ⇒ Abachrome::Color

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

This method converts LMS to LRGB first, then to OKLAB. The LMS color space represents the response of the three types of cone cells in the human eye.

the same alpha as the input color

Parameters:

Returns:

Raises:

  • (ArgumentError)

    If the input color is not in LMS color space



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

def self.convert(lms_color)
  raise_unless lms_color, :lms

  # Convert LMS to LRGB first
  lrgb_color = Converters::LmsToLrgb.convert(lms_color)

  # Then convert LRGB to OKLAB
  Converters::LrgbToOklab.convert(lrgb_color)
end