CssColor
Entrypoint for CSS color parsing and late resolution support.
Provides factory methods for creating resolvable CSS color expressions
and utilities for resolving them into concrete colors.
Methods
colorMix
static
public static function colorMix(string $space, CssResolvableInterface|ColorInterface|string $left, CssResolvableInterface|ColorInterface|string $right, float $w1, float $w2): CssResolvableInterface
Create a color-mix() expression.
Parameters
| Name | Type | Default |
|---|---|---|
$space |
string | - |
$left |
CssResolvableInterface|ColorInterface|string | - |
$right |
CssResolvableInterface|ColorInterface|string | - |
$w1 |
float | null |
$w2 |
float | null |
currentColor
static
public static function currentColor(): CssResolvableInterface
Create a currentColor expression.
from
static
public static function from(string $targetSpace, CssResolvableInterface|ColorInterface|string $origin, array $channels, string|float|null $alpha): CssResolvableInterface
Create a relative color expression.
Parameters
| Name | Type | Default |
|---|---|---|
$targetSpace |
string | - |
$origin |
CssResolvableInterface|ColorInterface|string | - |
$channels |
array | - |
$alpha |
string|float|null | null |
lightDark
static
public static function lightDark(CssResolvableInterface|ColorInterface|string $light, CssResolvableInterface|ColorInterface|string $dark): LightDarkColor
Create a light-dark() expression.
Parameters
| Name | Type | Default |
|---|---|---|
$light |
CssResolvableInterface|ColorInterface|string | - |
$dark |
CssResolvableInterface|ColorInterface|string | - |
mix
static
public static function mix(string $space, CssResolvableInterface|ColorInterface|string $left, CssResolvableInterface|ColorInterface|string $right, float $w1, float $w2): CssResolvableInterface
Create a color-mix() expression.
Parameters
| Name | Type | Default |
|---|---|---|
$space |
string | - |
$left |
CssResolvableInterface|ColorInterface|string | - |
$right |
CssResolvableInterface|ColorInterface|string | - |
$w1 |
float | null |
$w2 |
float | null |
parse
static
public static function parse(string $css): CssResolvableInterface
Parse a CSS color string into a resolvable expression.
Parameters
| Name | Type | Default |
|---|---|---|
$css |
string | - |
relative
static
public static function relative(string $targetSpace, CssResolvableInterface|ColorInterface|string $origin, array $channels, string|float|null $alpha): CssResolvableInterface
Create a relative color expression.
Parameters
| Name | Type | Default |
|---|---|---|
$targetSpace |
string | - |
$origin |
CssResolvableInterface|ColorInterface|string | - |
$channels |
array | - |
$alpha |
string|float|null | null |
resolve
static
public static function resolve(CssResolvableInterface|ColorInterface $expr, CssContext $ctx): ColorInterface|CssResolvableInterface
Resolve a CSS color expression into a concrete color.
Parameters
| Name | Type | Default |
|---|---|---|
$expr |
CssResolvableInterface|ColorInterface | - |
$ctx |
CssContext | - |
var
static
public static function var(string $name, CssResolvableInterface|ColorInterface|string|null $fallback): CssResolvableInterface
Create a CSS variable expression.
Parameters
| Name | Type | Default |
|---|---|---|
$name |
string | - |
$fallback |
CssResolvableInterface|ColorInterface|string|null | null |