Color Spaces
Compare supported color spaces, inspect their channels, and choose the coordinates that fit each operation.
sRGBrgb(128 110 174)OKLCH0.581141 0.0979163 296.154Lab50.1527 17.9308 -31.8549Display P30.491213 0.433759 0.666815The color stays visible while its coordinates change
Each space describes the same source through a different model. Choose coordinates for the operation, not because one notation is universally better.
Reference
Supported color spaces
Channels, syntax, and the job each coordinate system is designed to do.
oklch()
Design tokens, tonal scales, hue manipulation.
OKLab
Perceptual
oklab()
Mixing, interpolation, gradient construction.
LCH
Cylindrical
lch()
Hue-aware manipulation on the CIE side.
CIE Lab
Perceptual
lab()
Delta E distance, print and imaging pipelines.
sRGB
RGB
rgb()
Compatibility, hex output, legacy pipelines.
Linear sRGB
RGB
color(srgb-linear ...)
Physically correct blending and compositing.
Display P3
RGB
color(display-p3 ...)
Vivid UI color on wide-gamut displays.
A98 RGB
RGB
color(a98-rgb ...)
Photography and prepress interchange.
ProPhoto RGB
RGB
color(prophoto-rgb ...)
RAW photo editing headroom.
Rec. 2020
RGB
color(rec2020 ...)
HDR video and future-proof pipelines.
CIE XYZ
Foundation
color(xyz ...)
Colorimetry, adaptation, conversion plumbing.
HSL
Cylindrical
hsl()
Reading and writing legacy CSS.
HWB
Cylindrical
hwb()
Tint-and-shade picking, CSS Color 4 output.
CMYK
Print
device-cmyk()
Print previews and naive ink conversion.
Chromaticity
The CIE 1931 xy diagram places the visible spectrum and several RGB gamuts in one shared coordinate system.
Coordinates
Pick a space that matches the task
Cylindrical spaces expose hue directly, perceptual spaces support visually steady adjustments, and RGB spaces describe the output capabilities of real displays.
Perception
Build visible steps with perceptual coordinates
OKLCH and OKLab model visual differences more directly, making them useful for lightness scales, gradients, mixing, and controlled color adjustments.
OKLCH lightness
OKLCH hue
Gamuts
Target the colors a display can reproduce
sRGB, Display P3, Adobe RGB, and Rec.2020 describe different sets of displayable colors. PHPColor can inspect and convert values for the intended output space.
Conversion
Move between spaces through one workflow
Use the same to() method for every supported destination, then read channels, adjust the result, or serialize it in that space’s native syntax.
<?php
use PhpColor\Color\Color;
$source = Color::parse('#3b82f6');
$oklch = $source->to('oklch');
$p3 = $source->to('display-p3');
$lab = $source->to('lab');
use PhpColor\Color\Color;
$source = Color::parse('#3b82f6');
$oklch = $source->to('oklch');
$p3 = $source->to('display-p3');
$lab = $source->to('lab');