Purple
A deep, warm magenta with the energy of a warm sky.
Create Purple in PHP
Parse the catalog’s canonical value once, then keep the resulting color object throughout the rest of your code.
<?php
use PhpColor\Color\Color;
$purple = Color::parse('#800080');
use PhpColor\Color\Color;
$purple = Color::parse('#800080');
ColorInterface
$purple
#800080 · oklch(0.4209 0.1935 328.4)
Build a Purple harmony
tetradic() keeps Purple and adds three partners at equal quarter-turns around the OKLCH hue wheel.
<?php
$harmony = $purple->tetradic();
foreach ($harmony as $color) {
echo $color->toHex().PHP_EOL;
}
$harmony = $purple->tetradic();
foreach ($harmony as $color) {
echo $color->toHex().PHP_EOL;
}
- 0
#800080 - 1
#931700 - 2
#006600 - 3
#0051a8
Generate a Purple scale
Keep the original hue and chroma, then vary OKLCH lightness to produce perceptually ordered steps.
<?php
$oklch = $purple->to('oklch');
foreach ([0.97, 0.92, 0.84, 0.74, 0.66, 0.58, 0.48, 0.40, 0.32, 0.24, 0.16] as $lightness) {
$step = $oklch->withChannel('l', $lightness);
}
$oklch = $purple->to('oklch');
foreach ([0.97, 0.92, 0.84, 0.74, 0.66, 0.58, 0.48, 0.40, 0.32, 0.24, 0.16] as $lightness) {
$step = $oklch->withChannel('l', $lightness);
}
50
100
200
300
400
500
600
700
800
900
950
Format Purple for the web
The same object can emit a compact Hex value, an sRGB CSS function, or its perceptual OKLCH coordinates.
<?php
$hex = $purple->toHex();
$rgb = $purple->toCss('srgb');
$oklch = $purple->to('oklch')->toCss();
$hex = $purple->toHex();
$rgb = $purple->toCss('srgb');
$oklch = $purple->to('oklch')->toCss();
- hex
#800080- rgb
rgb(128 0 128)- oklch
oklch(0.420914 0.193453 328.363)