Module: Abachrome::ColorMixins::ToLms

Defined in:
lib/abachrome/color_mixins/to_lms.rb

Instance Method Summary collapse

Instance Method Details

#lms_arrayArray<AbcDecimal>

Returns an array representation of the color's coordinates in the LMS color space.

in the LMS color space in the order [L, M, S]

Returns:

  • (Array<AbcDecimal>)

    An array containing the coordinates of the color



99
100
101
# File 'lib/abachrome/color_mixins/to_lms.rb', line 99

def lms_array
  to_lms.coordinates
end

#lms_valuesArray<AbcDecimal>

Returns the LMS color space coordinates for this color.

Returns:

  • (Array<AbcDecimal>)

    An array of LMS coordinates [L, M, S] representing the color in LMS color space



91
92
93
# File 'lib/abachrome/color_mixins/to_lms.rb', line 91

def lms_values
  to_lms.coordinates
end

#longAbcDecimal

Returns the L component (long wavelength) from the LMS color space.

The L component represents the response of long-wavelength sensitive cone cells in the human eye, which are most sensitive to red light.

Returns:

  • (AbcDecimal)

    The L (long wavelength) value from the LMS color space



64
65
66
# File 'lib/abachrome/color_mixins/to_lms.rb', line 64

def long
  to_lms.coordinates[0]
end

#mediumAbcDecimal

Returns the M component (medium wavelength) from the LMS color space.

The M component represents the response of medium-wavelength sensitive cone cells in the human eye, which are most sensitive to green light.

Returns:

  • (AbcDecimal)

    The M (medium wavelength) value from the LMS color space



74
75
76
# File 'lib/abachrome/color_mixins/to_lms.rb', line 74

def medium
  to_lms.coordinates[1]
end

#shortAbcDecimal

Returns the S component (short wavelength) from the LMS color space.

The S component represents the response of short-wavelength sensitive cone cells in the human eye, which are most sensitive to blue light.

Returns:

  • (AbcDecimal)

    The S (short wavelength) value from the LMS color space



84
85
86
# File 'lib/abachrome/color_mixins/to_lms.rb', line 84

def short
  to_lms.coordinates[2]
end

#to_lmsAbachrome::Color

Converts the current color to the LMS color space.

If the color is already in LMS, it returns the color unchanged. Otherwise, it uses the Converter to transform the color to LMS.

Returns:



33
34
35
36
37
# File 'lib/abachrome/color_mixins/to_lms.rb', line 33

def to_lms
  return self if color_space.name == :lms

  Converter.convert(self, :lms)
end

#to_lms!Abachrome::Color

Converts the color to the LMS color space in place. This method transforms the current color into LMS space, modifying the original object by updating its color space and coordinates if not already in LMS.

color = Abachrome::Color.from_hex("#ff5500") color.to_lms! # Color now uses LMS color space

Returns:



49
50
51
52
53
54
55
56
# File 'lib/abachrome/color_mixins/to_lms.rb', line 49

def to_lms!
  unless color_space.name == :lms
    lms_color = to_lms
    @color_space = lms_color.color_space
    @coordinates = lms_color.coordinates
  end
  self
end