#806eae
0.5
#d97706
#ac7776
OklabColor
Use one ratio with two interpolation spaces and see the exact difference in the resulting color.
#806eae
0.5
#d97706
#ac7776
OklabColor
#806eae
0.5
#d97706
#ad735a
SrgbColor
The endpoints and ratio stay fixed. Oklab and linear-light sRGB take different paths between them and return different concrete color types.
Oklab is the default. The srgb option interpolates linearized sRGB channels rather than encoded channel numbers.
<?php
use PhpColor\Color\Color;
$source = Color::parse('#806eae');
$other = Color::parse('#d97706');
$oklab = Color::mix($source, $other, 0.5, 'oklab');
$srgb = Color::mix($source, $other, 0.5, 'srgb');
echo $oklab->toHex(); // #ac7776
echo $srgb->toHex(); // #ad735a
use PhpColor\Color\Color;
$source = Color::parse('#806eae');
$other = Color::parse('#d97706');
$oklab = Color::mix($source, $other, 0.5, 'oklab');
$srgb = Color::mix($source, $other, 0.5, 'srgb');
echo $oklab->toHex(); // #ac7776
echo $srgb->toHex(); // #ad735a
Color::mix() returns one point between two endpoints. Gradients add multiple stops, geometry, and repeated sampling. Mixing is also distinct from alpha compositing and blend modes.
Only oklab and srgb are supported. Names such as oklch, rgb, srgb-linear, and lab throw.
The ratio clamps to 0..1. Alpha interpolates linearly, and hexadecimal serialization quantizes the final channels.