Class: Abachrome::Converters::OklabToSrgb

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

Converts a color from the Oklab color space to the sRGB color space. This conversion is performed in two steps:

  1. First converts from Oklab to linear RGB

  2. Then converts from linear RGB to sRGB

Raises:

  • (ArgumentError)

    If the provided color is not in the Oklab color space



31
32
33
34
35
36
37
38
39
# File 'lib/abachrome/converters/oklab_to_srgb.rb', line 31

def self.convert(oklab_color)
  raise_unless oklab_color, :oklab

  # First convert Oklab to linear RGB
  lrgb_color = OklabToLrgb.convert(oklab_color)

  # Then use the LrgbToSrgb converter to go from linear RGB to sRGB
  LrgbToSrgb.convert(lrgb_color)
end