bicou/color-mixer

Spectral color mixer

dev-main 2025-05-11 10:31 UTC

This package is auto-updated.

Last update: 2025-05-11 10:33:03 UTC


README

This package provides a spectral color mixer for use with spatie/color or matthieumastadenis/couleur.

Based on Spectral.js, itself based on the Kubelka-Munk theory.

Installation

composer require bicou/color-mixer

Usage with spatie/color

use Spatie\Color\Hex;
use Bicou\ColorMixer\Spatie\SpatieMixer;

$yellow = Hex::fromString('#f2de24');
$blue = Hex::fromString('#3f58fc');

$mixer = new SpatieMixer($yellow, $blue);

$green = $mixer->at(0.5);
echo $green->toHex(); // #7ca64d

Usage with matthieumastadenis/couleur

use matthieumastadenis\couleur\colors\HexRgb;
use Bicou\ColorMixer\Couleur\CouleurMixer;

$yellow = new HexRgb('F2', 'DE', '24');
$blue = new HexRgb('3F', '58', 'FC');

$mixer = new CouleurMixer($yellow, $blue);

$green = $mixer->at(0.5);
echo $green->toHexRgb(); // #7CA64D