Generate color harmonies
Derive named hue relationships from one anchor without calculating each rotation yourself.
anchor
#e17363
+120 deg
#4eb068
+240 deg
#7792ee
Triadic
Generate an exact hue relationship
The anchor at 30 degrees produces two rotations at 150 and 270 degrees. Lightness, chroma, and alpha remain unchanged.
Choose a named geometry
Pass one color and a HarmonyPattern to the generator. The anchor remains first and the generated colors follow it in a new palette.
<?php
use PhpColor\Color\Color;
use PhpColor\Color\Palette\Harmony\HarmonyGenerator;
use PhpColor\Color\Palette\Harmony\HarmonyPattern;
$palette = (new HarmonyGenerator())->generate(
Color::parse('oklch(0.68 0.14 30)'),
HarmonyPattern::Triadic,
);
echo implode(', ', $palette->toHex());
// #e17363, #4eb068, #7792ee
use PhpColor\Color\Color;
use PhpColor\Color\Palette\Harmony\HarmonyGenerator;
use PhpColor\Color\Palette\Harmony\HarmonyPattern;
$palette = (new HarmonyGenerator())->generate(
Color::parse('oklch(0.68 0.14 30)'),
HarmonyPattern::Triadic,
);
echo implode(', ', $palette->toHex());
// #e17363, #4eb068, #7792ee
Change the geometry, not the workflow
Use analogous, complementary, split-complementary, triadic, or tetradic relationships through the same generator.
Complementary
Split complementary
Triadic
Tetradic
Geometry previews at constant OKLCH lightness and chroma, not serialized generator results.
Treat geometry as a starting point
A harmony describes hue relationships. It is not a verdict on visual quality or suitability.
The generated palette does not guarantee contrast, target-gamut membership, or semantic usefulness.
Harmony detection uses a tolerance and heuristic score, not a design judgment.
Evaluate the generated colors in the interface where they will appear.