OkLabColor
Interface representing a color in the OKLAB color space.Properties
Lightness component (0-1)
Green-red component (negative values represent green, positive values represent red)
Blue-yellow component (negative values represent blue, positive values represent yellow)
Optional alpha channel (0-1)
rgbToOkLab
Converts an RGB color to an OKLAB color.Parameters
The RGB color to convert. Must have
red, green, and blue properties (0-255), and an optional alpha property (0-1).Returns
An OKLAB color object with
l (lightness), a (green-red), b (blue-yellow), and optional alpha properties.Example
okLabToRgb
Converts an OKLAB color to an RGB color.Parameters
The OKLAB color to convert. Must have
l (lightness), a (green-red), and b (blue-yellow) properties, and an optional alpha property.Returns
An RGB color object with
red, green, blue, and optional alpha properties. Color values are clamped to the valid range (0-255) and rounded to integers.Example
About OKLAB
OKLAB is a perceptually uniform color space that:- Provides better perceptual uniformity than LAB
- Is optimized for modern display devices
- Works well for color interpolation and manipulation
- Uses a simple transformation from linear RGB
- Generating color palettes
- Creating smooth color gradients
- Adjusting colors while maintaining perceptual consistency
- Image processing operations