Color Objects¶
python-colormath has support for many of the commonly used color spaces. These are represented by Color objects.
SpectralColor¶
- class colormath.color_objects.SpectralColor(spec_340nm=0.0, spec_350nm=0.0, spec_360nm=0.0, spec_370nm=0.0, spec_380nm=0.0, spec_390nm=0.0, spec_400nm=0.0, spec_410nm=0.0, spec_420nm=0.0, spec_430nm=0.0, spec_440nm=0.0, spec_450nm=0.0, spec_460nm=0.0, spec_470nm=0.0, spec_480nm=0.0, spec_490nm=0.0, spec_500nm=0.0, spec_510nm=0.0, spec_520nm=0.0, spec_530nm=0.0, spec_540nm=0.0, spec_550nm=0.0, spec_560nm=0.0, spec_570nm=0.0, spec_580nm=0.0, spec_590nm=0.0, spec_600nm=0.0, spec_610nm=0.0, spec_620nm=0.0, spec_630nm=0.0, spec_640nm=0.0, spec_650nm=0.0, spec_660nm=0.0, spec_670nm=0.0, spec_680nm=0.0, spec_690nm=0.0, spec_700nm=0.0, spec_710nm=0.0, spec_720nm=0.0, spec_730nm=0.0, spec_740nm=0.0, spec_750nm=0.0, spec_760nm=0.0, spec_770nm=0.0, spec_780nm=0.0, spec_790nm=0.0, spec_800nm=0.0, spec_810nm=0.0, spec_820nm=0.0, spec_830nm=0.0, observer='2', illuminant='d50')[source]¶
A SpectralColor represents a spectral power distribution, as read by a spectrophotometer. Our current implementation has wavelength intervals of 10nm, starting at 340nm and ending at 830nm.
Spectral colors are the lowest level, most “raw” measurement of color. You may convert spectral colors to any other color space, but you can’t convert any other color space back to spectral.
See Spectral power distribution on Wikipedia for some higher level details on how these work.
Parameters: - observer (str) – Observer angle. Either '2' or '10' degrees.
- illuminant (str) – See Observers and Illuminants for valid values.
LabColor¶
- class colormath.color_objects.LabColor(lab_l, lab_a, lab_b, observer='2', illuminant='d50')[source]¶
Represents a CIE Lab color. For more information on CIE Lab, see Lab color space on Wikipedia.
Parameters:
LCHabColor¶
- class colormath.color_objects.LCHabColor(lch_l, lch_c, lch_h, observer='2', illuminant='d50')[source]¶
Represents an CIE LCH color that was converted to LCH by passing through CIE Lab. This differs from LCHuvColor, which was converted to LCH through CIE Luv.
See Introduction to Colour Spaces by Phil Cruse for an illustration of how CIE LCH differs from CIE Lab.
Parameters:
LCHuvColor¶
- class colormath.color_objects.LCHuvColor(lch_l, lch_c, lch_h, observer='2', illuminant='d50')[source]¶
Represents an CIE LCH color that was converted to LCH by passing through CIE Luv. This differs from LCHabColor, which was converted to LCH through CIE Lab.
See Introduction to Colour Spaces by Phil Cruse for an illustration of how CIE LCH differs from CIE Lab.
Parameters:
LuvColor¶
XYZColor¶
xyYColor¶
sRGBColor¶
- class colormath.color_objects.sRGBColor(rgb_r, rgb_g, rgb_b, is_upscaled=False)[source]¶
Represents an sRGB color.
Parameters: - rgb_r (float) – R coordinate. 0...1. 1-255 if is_upscaled=True.
- rgb_g (float) – G coordinate. 0...1. 1-255 if is_upscaled=True.
- rgb_b (float) – B coordinate. 0...1. 1-255 if is_upscaled=True.
- is_upscaled (bool) – If False, RGB coordinate values are beteween 0.0 and 1.0. If True, RGB values are between 1 and 255.
AdobeRGBColor¶
- class colormath.color_objects.AdobeRGBColor(rgb_r, rgb_g, rgb_b, is_upscaled=False)[source]¶
Represents an Adobe RGB color.
Parameters: - rgb_r (float) – R coordinate. 0...1. 1-255 if is_upscaled=True.
- rgb_g (float) – G coordinate. 0...1. 1-255 if is_upscaled=True.
- rgb_b (float) – B coordinate. 0...1. 1-255 if is_upscaled=True.
- is_upscaled (bool) – If False, RGB coordinate values are beteween 0.0 and 1.0. If True, RGB values are between 1 and 255.