Color Transformation

Adjust, mix, and chain immutable operations in perceptual color spaces.

Make colors lighter or darker

Derive lighter and darker variants by changing OKLCH lightness while leaving the source color unchanged.

Explore Lightness

Adjust color chroma

Increase or reduce OKLCH chroma with an explicit relative amount while preserving the source color.

Explore Chroma

Rotate color hue

Move one color by an explicit angle around the OKLCH hue circle and inspect the exact result.

Explore Hue

Adjust color alpha

Set an explicit alpha channel while preserving the source color channels and type.

Explore Alpha
<?php

use PhpColor\Color\Color;

$color = Color::parse('#7c3aed');
$translucent = $color->withAlpha(0.45);
use PhpColor\Color\Color; $color = Color::parse('#7c3aed'); $translucent = $color->withAlpha(0.45);

Convert colors to grayscale

Remove OKLCH chroma while retaining perceptual lightness, alpha, and the source object type.

Explore Grayscale
<?php

use PhpColor\Color\Color;

$gray = Color::parse('#7c3aed')->grayscale();
echo $gray->toHex(); // #6f6f6f
use PhpColor\Color\Color; $gray = Color::parse('#7c3aed')->grayscale(); echo $gray->toHex(); // #6f6f6f

Invert color channels

Invert encoded sRGB channels while preserving alpha and returning the source color type.

Explore Inversion
<?php

use PhpColor\Color\Color;

$inverted = Color::parse('#7c3aed')->invert();
echo $inverted->toHex(); // #83c512
use PhpColor\Color\Color; $inverted = Color::parse('#7c3aed')->invert(); echo $inverted->toHex(); // #83c512

Shift color temperature

Move an OKLCH hue toward a warmer or cooler target without changing lightness or chroma.

Explore Temperature
<?php

use PhpColor\Color\Color;

$color = Color::parse('#7c3aed');
$warmer = $color->warm(0.6);
$cooler = $color->cool(0.6);
use PhpColor\Color\Color; $color = Color::parse('#7c3aed'); $warmer = $color->warm(0.6); $cooler = $color->cool(0.6);

Mix colors in a chosen space

Select one exact point between two colors using Oklab or linear-light sRGB interpolation.

Explore Mixing

Blend colors by mode

Apply a named sRGB blend mode with explicit foreground, backdrop, and alpha order.

Explore Blending
<?php

use PhpColor\Color\Color;

$foreground = Color::parse('rgb(244 63 94 / 65%)');
$backdrop = Color::parse('#2563eb');
$result = $foreground->blend($backdrop, 'multiply');
use PhpColor\Color\Color; $foreground = Color::parse('rgb(244 63 94 / 65%)'); $backdrop = Color::parse('#2563eb'); $result = $foreground->blend($backdrop, 'multiply');

Composite translucent colors

Resolve a translucent foreground over a backdrop into the opaque sRGB color that viewers receive.

Explore Compositing
<?php

use PhpColor\Color\Color;
use PhpColor\Color\Contrast\ContrastSolver;

$foreground = Color::parse('rgb(244 63 94 / 65%)');
$backdrop = Color::parse('#2563eb');
$visible = ContrastSolver::composite($foreground, $backdrop);
use PhpColor\Color\Color; use PhpColor\Color\Contrast\ContrastSolver; $foreground = Color::parse('rgb(244 63 94 / 65%)'); $backdrop = Color::parse('#2563eb'); $visible = ContrastSolver::composite($foreground, $backdrop);

Build color tints

Generate an ordered collection from one source color through white using repeated Oklab mixes.

Explore Tints

Build color shades

Generate an ordered collection from one source color through black using repeated Oklab mixes.

Explore Shades

Build transformation chains

Combine immutable operations into reusable, inspectable color workflows.

Explore Transformation chains
<?php

use PhpColor\Color\Color;

$button = Color::parse('#806eae')
    ->to('oklch')
    ->withChannel('l', 0.65)
    ->desaturate(0.03)
    ->rotateHue(-4)
    ->to('srgb');
use PhpColor\Color\Color; $button = Color::parse('#806eae') ->to('oklch') ->withChannel('l', 0.65) ->desaturate(0.03) ->rotateHue(-4) ->to('srgb');

Keep building

Build readable, immutable color workflows