Repair palette harmony

Align mismatched source colors to a chosen hue relationship without rebuilding the palette.

Source palette Hue gaps: 157.0, 132.5, and 70.5 degrees
primary
#776aa6
secondary
#c8ae66
accent
#65a6bd
Irregular source hue geometry Three points around a hue circle form an irregular triangle with unequal angular gaps.
Triadic result Native target gaps: 120, 120, and 120 degrees
primary
#776aa6
secondary
#e19f76
accent
#68ab97
Triadic result geometry Three points around a hue circle form an equilateral triangle with 120 degree angular gaps.

Turn irregular hue spacing into an exact triad

The first color anchors the relationship. The fixer moves the other hues to 120 and 240 degrees from that anchor while retaining their individual lightness and chroma.

Choose the relationship to apply

Pass the source palette and a target pattern to HarmonyFixer. The method returns a new named palette and leaves the source untouched.

<?php

use PhpColor\Color\Palette\ColorPalette;
use PhpColor\Color\Palette\Fixer\HarmonyFixer;
use PhpColor\Color\Palette\Harmony\HarmonyPattern;

$source = ColorPalette::parse([
    'primary' => '#776aa6',
    'secondary' => '#c8ae66',
    'accent' => '#65a6bd',
]);

$fixed = (new HarmonyFixer())->fix($source, [
    'target_harmony' => HarmonyPattern::Triadic,
]);

print_r($fixed->toHex());
use PhpColor\Color\Palette\ColorPalette; use PhpColor\Color\Palette\Fixer\HarmonyFixer; use PhpColor\Color\Palette\Harmony\HarmonyPattern; $source = ColorPalette::parse([ 'primary' => '#776aa6', 'secondary' => '#c8ae66', 'accent' => '#65a6bd', ]); $fixed = (new HarmonyFixer())->fix($source, [ 'target_harmony' => HarmonyPattern::Triadic, ]); print_r($fixed->toHex());
Array
(
    [primary] => #776aa6
    [secondary] => #e19f76
    [accent] => #68ab97
)

Keep the palette structure intact

Harmony repair changes hue coordinates. It does not flatten the colors into copies of the anchor.

LightnessEach color keeps its own OKLCH lightness.
ChromaEach color keeps its own OKLCH chroma.
AlphaTransparency remains unchanged.
Names and orderNamed keys and palette order remain stable.

Use harmony repair for hue geometry

A geometric harmony is a defined relationship, not a universal judgment of visual quality. Test the result in its actual interface and against its other requirements.

The fixer follows palette order and uses one color as its anchor. Achromatic colors remain unchanged.

It does not repair scale progression, assign semantic roles, guarantee contrast, or keep every result inside a target gamut.

Choose a next step

Inspect the relationship or try another palette