Repair palette harmony
Align mismatched source colors to a chosen hue relationship without rebuilding the palette.
primary
#776aa6
secondary
#c8ae66
accent
#65a6bd
primary
#776aa6
secondary
#e19f76
accent
#68ab97
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.
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.