Shift color temperature

Move a hue toward PHPColor's warm or cool target while retaining lightness and chroma.

Warmer by 0.6 temperature 0.579 #ac15c1
Source temperature 0.256 #7c3aed
Cooler by 0.6 temperature -0.021 #3655fb

Move hue toward a defined direction

warm() moves toward 30 degrees and cool() toward 210 degrees in OKLCH. The amount controls half of the remaining angular distance.

Derive both directions from one source

The amount is clamped from 0 to 1. Both methods return a new object and keep the source available.

<?php

use PhpColor\Color\Color;

$source = Color::parse('#7c3aed');
$warm = $source->warm(0.6);
$cool = $source->cool(0.6);

printf("%s\n%s\n", $warm->toHex(), $cool->toHex());

// #ac15c1
// #3655fb
use PhpColor\Color\Color; $source = Color::parse('#7c3aed'); $warm = $source->warm(0.6); $cool = $source->cool(0.6); printf("%s\n%s\n", $warm->toHex(), $cool->toHex()); // #ac15c1 // #3655fb

Temperature is a hue model

The operation uses PHPColor's signed hue mapping. It does not model illumination, white balance, or correlated color temperature in kelvin.

Warm targetHue moves toward 30 degrees in OKLCH.
Cool targetHue moves toward 210 degrees in OKLCH.
StructureLightness, chroma, and alpha are retained before conversion.
GamutSerialized sRGB can clip a result outside the display gamut.

Choose a next step

Shift the hue while keeping the direction explicit