Make colors lighter or darker
Derive lighter and darker variants by changing OKLCH lightness while leaving the source color unchanged.
Explore LightnessAdjust, mix, and chain immutable operations in perceptual color spaces.
Derive lighter and darker variants by changing OKLCH lightness while leaving the source color unchanged.
Explore LightnessIncrease or reduce OKLCH chroma with an explicit relative amount while preserving the source color.
Explore ChromaMove one color by an explicit angle around the OKLCH hue circle and inspect the exact result.
Explore HueSet 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);
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 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
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);
Select one exact point between two colors using Oklab or linear-light sRGB interpolation.
Explore MixingApply 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');
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);
Generate an ordered collection from one source color through white using repeated Oklab mixes.
Explore TintsGenerate an ordered collection from one source color through black using repeated Oklab mixes.
Explore ShadesCombine 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');