Module: Abachrome::ColorMixins::ToLms
- Defined in:
- lib/abachrome/color_mixins/to_lms.rb
Instance Method Summary collapse
-
#lms_array ⇒ Array<AbcDecimal>
Returns an array representation of the color's coordinates in the LMS color space.
-
#lms_values ⇒ Array<AbcDecimal>
Returns the LMS color space coordinates for this color.
-
#long ⇒ AbcDecimal
Returns the L component (long wavelength) from the LMS color space.
-
#medium ⇒ AbcDecimal
Returns the M component (medium wavelength) from the LMS color space.
-
#short ⇒ AbcDecimal
Returns the S component (short wavelength) from the LMS color space.
-
#to_lms ⇒ Abachrome::Color
Converts the current color to the LMS color space.
-
#to_lms! ⇒ Abachrome::Color
Converts the color to the LMS color space in place.
Instance Method Details
#lms_array ⇒ Array<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]
99 100 101 |
# File 'lib/abachrome/color_mixins/to_lms.rb', line 99 def lms_array to_lms.coordinates end |
#lms_values ⇒ Array<AbcDecimal>
Returns the LMS color space coordinates for this color.
91 92 93 |
# File 'lib/abachrome/color_mixins/to_lms.rb', line 91 def lms_values to_lms.coordinates end |
#long ⇒ AbcDecimal
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.
64 65 66 |
# File 'lib/abachrome/color_mixins/to_lms.rb', line 64 def long to_lms.coordinates[0] end |
#medium ⇒ AbcDecimal
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.
74 75 76 |
# File 'lib/abachrome/color_mixins/to_lms.rb', line 74 def medium to_lms.coordinates[1] end |
#short ⇒ AbcDecimal
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.
84 85 86 |
# File 'lib/abachrome/color_mixins/to_lms.rb', line 84 def short to_lms.coordinates[2] end |
#to_lms ⇒ Abachrome::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.
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
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 |