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.154
Lab50.1527 17.9308 -31.8549
Display P30.491213 0.433759 0.666815

The 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.

Chromaticity

The CIE 1931 xy diagram places the visible spectrum and several RGB gamuts in one shared coordinate system.

sRGB A98 RGB Display P3 Rec. 2020 ProPhoto RGB D65 D50

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.

OKLCHBuild scales and adjust perceptual channels.
HSLUse familiar cylindrical CSS coordinates.
Display P3Target a wider display gamut.
XYZConnect device-dependent and perceptual spaces.

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.

sRGBThe common web and application baseline.
Display P3A wider gamut available on many modern displays.
Adobe RGBA professional RGB space with strong green coverage.
Rec.2020A broad-gamut space used by modern video standards.

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');

Go deeper

Choose a space for the work ahead