Functions for CIE L*a*b* and CIE L*C*h_ab conversions and pipelines to/from XYZ and sRGB.
RANGE CONVENTIONS:
==================
Input/Output Ranges:
- XYZ: X,Y,Z in 0-1 scale (Y=1 for white point)
- Lab: L in 0-100, a/b typically -128 to +127
- LCh: L in 0-100, C in 0+, h in 0-360 degrees
- sRGB: r,g,b in 0-1
Internal Processing:
- Reference white (D65): X=95.047, Y=100, Z=108.883 (0-100 scale)
- XYZ inputs are scaled from 0-1 to 0-100 for CIELAB math
- XYZ outputs are scaled from 0-100 back to 0-1
IMPORTANT:
- None of these functions perform any clamping
- Out-of-gamut colors will produce values outside typical ranges
- Clamping should be applied separately when needed
Methods
(static) labToLch(labColor) → {LchColor}
Converts CIELAB to CIELCh (cylindrical representation).
Parameters:
Name | Type | Description |
---|---|---|
labColor |
LabColor | CIELAB color { L, a, b }. |
Returns:
CIELCh color { L, C, h }.
- Type
- LchColor
(static) labToSrgb(labColor, referenceWhiteopt) → {SrgbColor}
Converts CIELAB directly to sRGB.
Optimized implementation that bypasses intermediate XYZ object creation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
labColor |
LabColor | CIELAB color { L, a, b }. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
sRGB color { r, g, b } with values 0-1.
- Type
- SrgbColor
(static) labToXyz(labColor, referenceWhiteopt) → {XyzColor}
Converts CIELAB to CIE XYZ.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
labColor |
LabColor | CIELAB color { L, a, b }. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
XYZ color with values in 0-1 range.
- Type
- XyzColor
(static) lchToLab(lchColor) → {LabColor}
Converts CIELCh to CIELAB.
Parameters:
Name | Type | Description |
---|---|---|
lchColor |
LchColor | CIELCh color { L, C, h }. |
Returns:
CIELAB color { L, a, b }.
- Type
- LabColor
(static) lchToSrgb(lchColor, referenceWhiteopt) → {SrgbColor}
Converts CIELCh to sRGB.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
lchColor |
LchColor | CIELCh color { L, C, h }. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
sRGB color { r, g, b } with values 0-1.
- Type
- SrgbColor
(static) srgbToLab(srgbColor, referenceWhiteopt) → {LabColor}
Converts sRGB directly to CIELAB.
Optimized implementation that bypasses intermediate XYZ object creation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srgbColor |
SrgbColor | sRGB color { r, g, b } with values 0-1. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
CIELAB color { L, a, b }.
- Type
- LabColor
(static) srgbToLch(srgbColor, referenceWhiteopt) → {LchColor}
Converts sRGB to CIELCh.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srgbColor |
SrgbColor | sRGB color { r, g, b } with values 0-1. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
CIELCh color { L, C, h }.
- Type
- LchColor
(static) xyzToLab(xyzColor, referenceWhiteopt) → {LabColor}
Converts CIE XYZ to CIELAB.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
xyzColor |
XyzColor | XYZ color with values in 0-1 range. | ||
referenceWhite |
Object |
<optional> |
D65_WHITE_POINT_XYZ | Reference white point. |
Returns:
CIELAB color { L, a, b }.
- Type
- LabColor