Documentation

Color
in package

Pop color class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
2.0.0

Table of Contents

Methods

cmyk()  : Cmyk
Instantiate a CMYK color object
grayscale()  : Grayscale
Instantiate a grayscale color object
hex()  : Hex
Instantiate a Hex color object
hsb()  : Hsb
Instantiate an HSB color object
hsl()  : Hsl
Instantiate an HSL color object
hsv()  : Hsv
Instantiate an HSV color object
hwb()  : Hwb
Instantiate an HWB color object
lab()  : Lab
Instantiate a CIE Lab color object
lch()  : Lch
Instantiate a CIE LCH color object
oklab()  : Oklab
Instantiate an Oklab color object
oklch()  : Oklch
Instantiate an Oklch color object
parse()  : ColorInterface
Parse color from string
parseColorValues()  : array<string|int, mixed>
Parse color values from string
rgb()  : Rgb
Instantiate an RGB color object
parseCmyk()  : Cmyk
Parse a space-separated CMYK string, converting an out-of-range OutOfRangeException into the documented Color\Exception rather than letting it leak from parse()
parseHwb()  : Hwb
Parse an HWB string, accepting either comma-separated values or native CSS Color 4 space-separated syntax (with an optional `/ alpha` suffix), converting an out-of-range or malformed-input exception into the documented Color\Exception rather than letting it leak from parse()
parseLabFamily()  : Lab|Lch|Oklab|Oklch
Parse a Lab-family (Lab/Lch/Oklab/Oklch) string, accepting either comma-separated values or native CSS Color 4 space-separated syntax (with an optional `/ alpha` suffix), converting an out-of-range or malformed-input exception into the documented Color\Exception rather than letting it leak from parse()

Methods

cmyk()

Instantiate a CMYK color object

public static cmyk(int $c, int $m, int $y, int $k) : Cmyk
Parameters
$c : int
$m : int
$y : int
$k : int
Return values
Cmyk

grayscale()

Instantiate a grayscale color object

public static grayscale(int $gray) : Grayscale
Parameters
$gray : int
Return values
Grayscale

hex()

Instantiate a Hex color object

public static hex(string $hex) : Hex
Parameters
$hex : string
Return values
Hex

hsb()

Instantiate an HSB color object

public static hsb(int $h, int $s, int $b[, float|null $a = null ]) : Hsb
Parameters
$h : int
$s : int
$b : int
$a : float|null = null
Return values
Hsb

hsl()

Instantiate an HSL color object

public static hsl(int $h, int $s, int $l[, float|null $a = null ]) : Hsl
Parameters
$h : int
$s : int
$l : int
$a : float|null = null
Return values
Hsl

hsv()

Instantiate an HSV color object

public static hsv(int $h, int $s, int $v[, float|null $a = null ]) : Hsv
Parameters
$h : int
$s : int
$v : int
$a : float|null = null
Return values
Hsv

hwb()

Instantiate an HWB color object

public static hwb(int $h, int $w, int $b[, float|null $a = null ]) : Hwb
Parameters
$h : int
$w : int
$b : int
$a : float|null = null
Return values
Hwb

lab()

Instantiate a CIE Lab color object

public static lab(float|string $l, float|string $a, float|string $b[, float|string|null $alpha = null ]) : Lab
Parameters
$l : float|string
$a : float|string
$b : float|string
$alpha : float|string|null = null
Return values
Lab

lch()

Instantiate a CIE LCH color object

public static lch(float|string $l, float|string $c, int|string $h[, float|string|null $alpha = null ]) : Lch
Parameters
$l : float|string
$c : float|string
$h : int|string
$alpha : float|string|null = null
Return values
Lch

oklab()

Instantiate an Oklab color object

public static oklab(float|string $l, float|string $a, float|string $b[, float|string|null $alpha = null ]) : Oklab
Parameters
$l : float|string
$a : float|string
$b : float|string
$alpha : float|string|null = null
Return values
Oklab

oklch()

Instantiate an Oklch color object

public static oklch(float|string $l, float|string $c, int|string $h[, float|string|null $alpha = null ]) : Oklch
Parameters
$l : float|string
$c : float|string
$h : int|string
$alpha : float|string|null = null
Return values
Oklch

parseColorValues()

Parse color values from string

public static parseColorValues(string $colorString[, bool $comma = true ]) : array<string|int, mixed>
Parameters
$colorString : string
$comma : bool = true
Return values
array<string|int, mixed>

rgb()

Instantiate an RGB color object

public static rgb(int $r, int $g, int $b[, float|null $a = null ]) : Rgb
Parameters
$r : int
$g : int
$b : int
$a : float|null = null
Return values
Rgb

parseCmyk()

Parse a space-separated CMYK string, converting an out-of-range OutOfRangeException into the documented Color\Exception rather than letting it leak from parse()

private static parseCmyk(string $colorString) : Cmyk
Parameters
$colorString : string
Tags
throws
Exception
Return values
Cmyk

parseHwb()

Parse an HWB string, accepting either comma-separated values or native CSS Color 4 space-separated syntax (with an optional `/ alpha` suffix), converting an out-of-range or malformed-input exception into the documented Color\Exception rather than letting it leak from parse()

private static parseHwb(string $colorString) : Hwb
Parameters
$colorString : string
Tags
throws
Exception
Return values
Hwb

parseLabFamily()

Parse a Lab-family (Lab/Lch/Oklab/Oklch) string, accepting either comma-separated values or native CSS Color 4 space-separated syntax (with an optional `/ alpha` suffix), converting an out-of-range or malformed-input exception into the documented Color\Exception rather than letting it leak from parse()

private static parseLabFamily(string $colorString, string $class) : Lab|Lch|Oklab|Oklch
Parameters
$colorString : string
$class : string
Tags
throws
Exception
Return values
Lab|Lch|Oklab|Oklch

        
On this page

Search results