OklchColor

Represents a color in the Oklch color space.

Oklch is a cylindrical representation of the Oklab color space, using
lightness (L), chroma (C), and hue (H). It is highly intuitive for
color design and manipulation.

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

fromOklab

static
public static function fromOklab(OklabColor $oklab): static

Create an Oklch color from an Oklab color instance.

Parameters
NameTypeDefault
$oklab OklabColor -

fromSrgb

static
public static function fromSrgb(SrgbColor $srgb): static
Parameters
NameTypeDefault
$srgb SrgbColor -
public function getAlpha(): float
public function getChannels(): array
public function getChroma(): float

Get the chroma component value.

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 an oklch() color string into an Oklch 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 toOklab(): OklabColor

Convert the color to its Oklab representation.

public function toOklch(): OklchColor
public function toSrgb(): SrgbColor
public function toString(): string
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 -