Advanced color conversions for special color spaces.
Includes:
- CIE XYZ
- CIELAB
- YUV (BT.601)
- YCbCr (BT.601)
- Color temperature (Kelvin)
- Delta E (color distance)
- WCAG contrast
Summary
Functions
Calculates the WCAG 2.1 contrast ratio between two colors.
Calculates the Delta E 1976 distance between two colors.
Converts CIELAB to RGB (sRGB D65).
Converts CIE XYZ to RGB (sRGB D65).
Converts YCbCr (BT.601) to RGB.
Converts YUV (BT.601) to RGB.
Converts temperature in Kelvin to RGB.
Finds the closest Pantone color for an RGB color.
Finds the closest Pantone name for an RGB color.
Returns only the name, or nil if there is no close match.
Calculates the WCAG 2.1 relative luminance of a color.
Approximates the correlated color temperature (CCT) in Kelvin from an RGB color.
Converts RGB to CIELAB (D65 illuminant).
Converts RGB to CIE XYZ using the sRGB D65 matrix.
Converts RGB to YCbCr (BT.601, digital video).
Converts RGB to YUV (BT.601, PAL/NTSC broadcast).
Types
Functions
Calculates the WCAG 2.1 contrast ratio between two colors.
WCAG AA requiere 4.5:1 para texto normal, 7:1 para AAA.
Calculates the Delta E 1976 distance between two colors.
This is the Euclidean distance in CIELAB space. Values < 1.0 are imperceptible.
Converts CIELAB to RGB (sRGB D65).
Converts CIE XYZ to RGB (sRGB D65).
Converts YCbCr (BT.601) to RGB.
Converts YUV (BT.601) to RGB.
@spec kelvin_to_rgb(pos_integer()) :: rgb()
Converts temperature in Kelvin to RGB.
Based on Tanner Helland's algorithm for black-body radiation approximation.
Finds the closest Pantone color for an RGB color.
Uses a curated list of popular Pantone colors and searches for the closest match using Delta E distance in CIELAB space.
Parameters
rgb- RGB tuple{r, g, b}
Returns
- tuple
{pantone_name, distance}ornilif there is no close match
Example
iex> Pote.Converters.Advanced.nearest_pantone({255, 0, 0})
{"Red 032 C", 0.0}
Finds the closest Pantone name for an RGB color.
Returns only the name, or nil if there is no close match.
Example
iex> Pote.Converters.Advanced.nearest_pantone_name({255, 0, 0})
"Red 032 C"
Calculates the WCAG 2.1 relative luminance of a color.
@spec rgb_to_kelvin(rgb()) :: pos_integer() | nil
Approximates the correlated color temperature (CCT) in Kelvin from an RGB color.
Uses an iterative search over kelvin_to_rgb/1 to find the
closest matching temperature.
Converts RGB to CIELAB (D65 illuminant).
Converts RGB to CIE XYZ using the sRGB D65 matrix.
Converts RGB to YCbCr (BT.601, digital video).
Converts RGB to YUV (BT.601, PAL/NTSC broadcast).