CallableColorPaletteTransformer
Transforms a color palette by applying a callable to each color.
This flexible transformer allows you to create custom transformations
by passing any callable that transforms a single color.
Example: Create a sepia transformer
php
$sepia = new CallableColorPaletteTransformer(function (ColorInterface $color): ColorInterface {
$oklch = $color->to('oklch');
return new OklchColor($oklch->l, min(0.1, $oklch->c), 70.0, $oklch->alpha);
});
$sepiaPalette = $sepia->transform($palette);Methods
public function transform(ColorPalette $palette): ColorPalette
Parameters
| Name | Type | Default |
|---|---|---|
$palette |
ColorPalette | - |