LabColor

Represents a color in the CIELAB color space.

CIELAB (or Lab) is a device-independent color space that covers the entire
range of human color perception. Components are lightness (L), and two
color-opponent dimensions (a and b). As specified by CSS Color 4 and ICC,
it uses a D50 white point, so the D65 pipeline is adapted with Bradford.

Methods

public function analogous(int $count): array
Parameters
NameTypeDefault
$count int 2
public function blend(ColorInterface|string $backdrop, string $mode): static
Parameters
NameTypeDefault
$backdrop ColorInterface|string -
$mode string "normal"
public function complementary(): static
public function cool(float $amount): static
Parameters
NameTypeDefault
$amount float -
public function darken(float $amount): static
Parameters
NameTypeDefault
$amount float -
public function desaturate(float $amount): static
Parameters
NameTypeDefault
$amount float -
public function equals(ColorInterface $other): bool
Parameters
NameTypeDefault
$other ColorInterface -

from

static
public static function from(ColorInterface|string $input): static
Parameters
NameTypeDefault
$input ColorInterface|string -

fromChannels

static
public static function fromChannels(array $channels, float $alpha): static

Create color from channel values.

Parameters
NameTypeDefault
$channels array -
$alpha float 1

fromSrgb

static
public static function fromSrgb(SrgbColor $srgb): static
Parameters
NameTypeDefault
$srgb SrgbColor -

fromXyz

static
public static function fromXyz(XyzColor $xyz): static

Create a Lab color from an XYZ color instance.

Parameters
NameTypeDefault
$xyz XyzColor -
public function getA(): float

Get the 'a' component value.

public function getAlpha(): float
public function getB(): float

Get the 'b' component value.

public function getChannels(): array
public function getHue(): float
public function getLightness(): float

Get the lightness component value.

public function getLuminance(): float
public function getOpacity(): float
public function getSaturation(): float

getSpaceName

static
public static function getSpaceName(): string
public function grayscale(): static
public function invert(): static
public function isCold(): bool
public function isDark(): bool
public function isHot(): bool
public function isLight(): bool
public function isOpaque(): bool
public function isTransparent(): bool
public function lighten(float $amount): static
Parameters
NameTypeDefault
$amount float -

parse

static
public static function parse(string $color): static

Parse a lab() color string into a Lab color instance.

Parameters
NameTypeDefault
$color string -
public function rotateHue(float $degrees): static
Parameters
NameTypeDefault
$degrees float -
public function saturate(float $amount): static
Parameters
NameTypeDefault
$amount float -
public function shade(float $t): static
Parameters
NameTypeDefault
$t float -
public function splitComplementary(): array
public function temperature(): float
public function tetradic(): array
public function tint(float $t): static
Parameters
NameTypeDefault
$t float -

to

public function to(ColorInterface|string $space): ColorInterface
Parameters
NameTypeDefault
$space ColorInterface|string -
public function toCss(string $space): string
Parameters
NameTypeDefault
$space string null
public function toHex(bool $withAlpha): string
Parameters
NameTypeDefault
$withAlpha bool false
public function toOklch(): OklchColor
public function toSrgb(): SrgbColor
public function toString(): string
public function toXyz(): XyzColor

Convert the color to its XYZ representation.

public function triadic(): array

tryFrom

static
public static function tryFrom(ColorInterface|string $input): static
Parameters
NameTypeDefault
$input ColorInterface|string -
public function warm(float $amount): static
Parameters
NameTypeDefault
$amount float -
public function withAlpha(float $alpha): static
Parameters
NameTypeDefault
$alpha float 1
public function withChannel(string $name, int|float $value): static
Parameters
NameTypeDefault
$name string -
$value int|float -
public function withChannels(array $partial): static
Parameters
NameTypeDefault
$partial array -