Classify colors as warm or cool

Use a signed hue score while keeping the neutral boundary visible.

oklch hue 30 - score 0.667 warm
oklch hue 90 - score 0 neutral
oklch hue 210 - score -0.667 cool

Keep zero as its own state

isHot() tests for a positive score and isCold() for a negative score. A score of exactly zero satisfies neither predicate.

Inspect the score behind the booleans

temperature() maps OKLCH hue to a signed value from -1 to 1. The booleans only test its sign.

<?php

use PhpColor\Color\OklchColor;

foreach ([30.0, 90.0, 210.0] as $hue) {
    $color = new OklchColor(0.7, 0.15, $hue);
    printf("%s %.6f hot=%d cold=%d\n",
        $color->toHex(),
        $color->temperature(),
        $color->isHot(),
        $color->isCold(),
    );
}

// #ed7665 0.666667 hot=1 cold=0
// #c39900 0.000000 hot=0 cold=0
// #00b6d1 -0.666667 hot=0 cold=1
use PhpColor\Color\OklchColor; foreach ([30.0, 90.0, 210.0] as $hue) { $color = new OklchColor(0.7, 0.15, $hue); printf("%s %.6f hot=%d cold=%d\n", $color->toHex(), $color->temperature(), $color->isHot(), $color->isCold(), ); } // #ed7665 0.666667 hot=1 cold=0 // #c39900 0.000000 hot=0 cold=0 // #00b6d1 -0.666667 hot=0 cold=1

Temperature is a project classification

The score describes hue placement. It is not a physical light temperature, a kelvin value, or a universal semantic judgment.

Warmtemperature() is greater than zero.
Cooltemperature() is less than zero.
NeutralA zero score is neither hot nor cold.
Achromatic colorsA hue coordinate can remain numerically present when chroma is near zero.

Choose a next step

Read the score before using the classification