ColorPalette
Concrete implementation of a color palette.
Methods
public function all(): array
builder
static
public static function builder(ColorInterface|string|null $base): ColorPaletteBuilder
Create a palette builder, optionally starting from a base color.
Parameters
| Name | Type | Default |
|---|---|---|
$base |
ColorInterface|string|null | null |
public function closest(ColorInterface $target, ColorDistanceInterface $metric): ColorInterface
Parameters
| Name | Type | Default |
|---|---|---|
$target |
ColorInterface | - |
$metric |
ColorDistanceInterface | null |
public function count(): int
public function desaturate(float $amount): static
Parameters
| Name | Type | Default |
|---|---|---|
$amount |
float | - |
fromHex
static
public static function fromHex(array $hexColors): ColorPalette
Parameters
| Name | Type | Default |
|---|---|---|
$hexColors |
array | - |
public function get(string|int $key): ColorInterface
Parameters
| Name | Type | Default |
|---|---|---|
$key |
string|int | - |
public function getIterator(): Traversable
interpolate
static
public static function interpolate(ColorInterface $start, ColorInterface $end, int $steps, string $space): ColorPalette
Create a palette by interpolating between two colors.
Parameters
| Name | Type | Default |
|---|---|---|
$start |
ColorInterface | - |
$end |
ColorInterface | - |
$steps |
int | 10 |
$space |
string | "oklab" |
public function isNamed(): bool
lightnessScale
static
public static function lightnessScale(ColorInterface $color, int $steps, float $min, float $max): ColorPalette
Create a palette of evenly spaced OKLCH lightness steps from one color.
Parameters
| Name | Type | Default |
|---|---|---|
$color |
ColorInterface | - |
$steps |
int | 10 |
$min |
float | 0.05 |
$max |
float | 0.95 |
public function merge(ColorPaletteInterface $other): static
Parameters
| Name | Type | Default |
|---|---|---|
$other |
ColorPaletteInterface | - |
named
static
public static function named(array $colors): ColorPalette
Parameters
| Name | Type | Default |
|---|---|---|
$colors |
array | - |
public function names(): array
parse
static
public static function parse(array $cssColors): ColorPalette
Parameters
| Name | Type | Default |
|---|---|---|
$cssColors |
array | - |
public function reverse(): static
public function rotateHue(float $degrees): static
Parameters
| Name | Type | Default |
|---|---|---|
$degrees |
float | - |
scale
static
public static function scale(array $colors): ColorPalette
Parameters
| Name | Type | Default |
|---|---|---|
$colors |
array | - |
shades
static
public static function shades(ColorInterface $color, int $steps): ColorPalette
Create a palette of shades toward black from one color.
Parameters
| Name | Type | Default |
|---|---|---|
$color |
ColorInterface | - |
$steps |
int | 5 |
public function slice(int $offset, int $length): static
Parameters
| Name | Type | Default |
|---|---|---|
$offset |
int | - |
$length |
int | null |
tints
static
public static function tints(ColorInterface $color, int $steps): ColorPalette
Create a palette of tints toward white from one color.
Parameters
| Name | Type | Default |
|---|---|---|
$color |
ColorInterface | - |
$steps |
int | 5 |
public function toCssVariables(string $prefix): string
Parameters
| Name | Type | Default |
|---|---|---|
$prefix |
string | "color" |
public function toHex(): array