Documentation

Rgb extends AbstractColor
in package

Pop Color RGB 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

Constants

COMMA  = 'COMMA'
String formats
CSS  = 'CSS'
PERCENT  = 'PERCENT'

Properties

$a  : float|null
Alpha value
$b  : int
B value
$g  : int
G value
$r  : int
R value

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Magic method to return the color value
__isset()  : bool
Magic method to return whether the color value exists
__set()  : void
Magic method to set the color value
__toString()  : string
Return CSS-formatted string
__unset()  : void
Magic method to unset color value
delinearize()  : float
Convert a linear-light sRGB channel value (0-1) back to its gamma-encoded equivalent
getA()  : float|null
Get A value
getB()  : int
Get B value
getG()  : int
Get G value
getR()  : int
Get R value
hasA()  : bool
Determine if the color object has an alpha value
hasAlpha()  : bool
Determine if the color object has an alpha value (alias)
linearize()  : float
Convert a gamma-encoded sRGB channel value (0-1) to its linear-light equivalent
offsetExists()  : bool
ArrayAccess offsetExists
offsetGet()  : mixed
ArrayAccess offsetGet
offsetSet()  : void
ArrayAccess offsetSet
offsetUnset()  : void
ArrayAccess offsetUnset
render()  : string
Convert to readable string
setA()  : self
Set A value
setB()  : self
Set B value
setG()  : self
Set G value
setR()  : self
Set R value
toArray()  : array<string|int, mixed>
Convert to array
toCmyk()  : Cmyk
Convert to CMYK
toCss()  : string
Convert to a CSS-formatted string, regardless of the class's default __toString() format
toGray()  : Grayscale
Convert to Gray
toHex()  : Hex
Convert to hex
toHsb()  : Hsb
Convert to HSB
toHsl()  : Hsl
Convert to HSL
toHsv()  : Hsv
Convert to HSV
toHwb()  : Hwb
Convert to HWB
toLab()  : Lab
Convert to CIE Lab
toLch()  : Lch
Convert to CIE LCH
toOklab()  : Oklab
Convert to Oklab
toOklch()  : Oklch
Convert to Oklch
channels()  : array<string|int, mixed>
Get the valid channel names
channelsForError()  : string
Format the valid channel names for an exception message, e.g. "'r', 'g', 'b' or 'a'"
labF()  : float
CIE Lab f() nonlinearity

Constants

Properties

$a

Alpha value

protected float|null $a = null

$b

B value

protected int $b = 0

$g

G value

protected int $g = 0

$r

R value

protected int $r = 0

Methods

__construct()

Constructor

public __construct(int|string $r, int|string $g, int|string $b[, float|string|null $a = null ]) : mixed

Instantiate the CSS RGB color object

Parameters
$r : int|string
$g : int|string
$b : int|string
$a : float|string|null = null

__get()

Magic method to return the color value

public __get(string $name) : mixed
Parameters
$name : string
Tags
throws
Exception

__isset()

Magic method to return whether the color value exists

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

Magic method to set the color value

public __set(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Tags
throws
Exception

__toString()

Return CSS-formatted string

public __toString() : string
Return values
string

__unset()

Magic method to unset color value

public __unset(string $name) : void
Parameters
$name : string
Tags
throws
Exception

delinearize()

Convert a linear-light sRGB channel value (0-1) back to its gamma-encoded equivalent

public static delinearize(float $value) : float
Parameters
$value : float
Return values
float

getA()

Get A value

public getA() : float|null
Return values
float|null

getB()

Get B value

public getB() : int
Return values
int

getG()

Get G value

public getG() : int
Return values
int

getR()

Get R value

public getR() : int
Return values
int

hasA()

Determine if the color object has an alpha value

public hasA() : bool
Return values
bool

hasAlpha()

Determine if the color object has an alpha value (alias)

public hasAlpha() : bool
Return values
bool

linearize()

Convert a gamma-encoded sRGB channel value (0-1) to its linear-light equivalent

public static linearize(float $value) : float
Parameters
$value : float
Return values
float

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

ArrayAccess offsetGet

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
throws
Exception

offsetSet()

ArrayAccess offsetSet

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Tags
throws
Exception

offsetUnset()

ArrayAccess offsetUnset

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Tags
throws
Exception

render()

Convert to readable string

public render([string|null $format = null ]) : string
Parameters
$format : string|null = null
Return values
string

setA()

Set A value

public setA(float|string $a) : self
Parameters
$a : float|string
Tags
throws
OutOfRangeException
Return values
self

setB()

Set B value

public setB(int|string $b) : self
Parameters
$b : int|string
Tags
throws
OutOfRangeException
Return values
self

setG()

Set G value

public setG(int|string $g) : self
Parameters
$g : int|string
Tags
throws
OutOfRangeException
Return values
self

setR()

Set R value

public setR(int|string $r) : self
Parameters
$r : int|string
Tags
throws
OutOfRangeException
Return values
self

toArray()

Convert to array

public toArray([bool $assoc = true ]) : array<string|int, mixed>
Parameters
$assoc : bool = true
Return values
array<string|int, mixed>

toCmyk()

Convert to CMYK

public toCmyk() : Cmyk
Return values
Cmyk

toCss()

Convert to a CSS-formatted string, regardless of the class's default __toString() format

public toCss() : string
Return values
string

toHex()

Convert to hex

public toHex() : Hex
Return values
Hex

toHsb()

Convert to HSB

public toHsb() : Hsb
Return values
Hsb

toHsl()

Convert to HSL

public toHsl() : Hsl
Return values
Hsl

toHsv()

Convert to HSV

public toHsv() : Hsv
Return values
Hsv

toHwb()

Convert to HWB

public toHwb() : Hwb
Return values
Hwb

toLab()

Convert to CIE Lab

public toLab() : Lab
Return values
Lab

toLch()

Convert to CIE LCH

public toLch() : Lch
Return values
Lch

toOklab()

Convert to Oklab

public toOklab() : Oklab
Return values
Oklab

toOklch()

Convert to Oklch

public toOklch() : Oklch
Return values
Oklch

channels()

Get the valid channel names

protected channels() : array<string|int, mixed>
Return values
array<string|int, mixed>

channelsForError()

Format the valid channel names for an exception message, e.g. "'r', 'g', 'b' or 'a'"

protected channelsForError() : string
Return values
string

labF()

CIE Lab f() nonlinearity

private static labF(float $t, float $epsilon, float $kappa) : float
Parameters
$t : float
$epsilon : float
$kappa : float
Return values
float

        
On this page

Search results