Table of contents
Namespace: Com\Tecnick\Color\Model
Extends: Model
File: Lab.php line 34
CIE Lab Color Model class
Tags
- since: 2015-02-21
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2015-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-color
Methods
__construct()
File: Lab.php line 86
public __construct(array<string, int|float|string> $components) : mixed
L* is clamped to [0..100], a* and b* to [-128..127] and alpha to [0..1].
Parameters
- $components : array<string, int|float|string>: Color components.
Tags
- throws: UnknownComponentException if a component name is not defined by this model
create()
File: Model.php line 76
public static create(ColorModelType|string $type[, array<string, int|float|string> $components = [] ]) : self
Parameters
- $type : ColorModelType|string: Color model type.
- $components : array<string, int|float|string> = []: Color components.
Tags
- throws: Exception if the type is unknown
- throws: UnknownComponentException if a component name is not defined by the model
Return values
self
getArray()
File: Lab.php line 100
public getArray() : array<string, float>
Return values
array<string, float> —
with keys (‘L’, ‘a’, ‘b’, ‘A’)
getComponentsString()
File: Lab.php line 189
public getComponentsString() : string
Return values
string
getCssColor()
File: Lab.php line 156
public getCssColor() : string
Components are emitted in fixed notation with up to 4 decimals.
Return values
string
getHexValue()
File: Model.php line 401
public getHexValue(float $value, int $max) : string
The result is zero-padded to 2 digits.
Parameters
- $value : float: Fraction value to convert [0..1]
- $max : int: Maximum value to return (reference value) [0..255]
Return values
string
getJsPdfColor()
File: Lab.php line 176
public getJsPdfColor() : string
Return values
string
getNormalizedArray()
File: Lab.php line 141
public getNormalizedArray(int $max) : array<string, float>
NOTE: the $max argument is not applied here. L* is returned in its own [0..100] range, a* and b* in [-128..127], and alpha is a fraction component kept in the [0..1] range.
Parameters
- $max : int: Unused; kept for interface compatibility.
Return values
array<string, float> —
with keys (‘L’, ‘a’, ‘b’, ‘A’)
getNormalizedValue()
File: Model.php line 361
public getNormalizedValue(float $value, int $max) : float
Parameters
- $value : float: Fraction value to convert [0..1]
- $max : int: Maximum value to return (reference value)
Return values
float —
value [0..$max]
getPDFacArray()
File: Lab.php line 120
public getPDFacArray() : array<string|int, float>
The values are in the range 0.0 to 1.0 and the number of array elements determines the color space: 3 = DeviceRGB
Return values
array<string|int, float> —
DeviceRGB color components (‘R’, ‘G’, ‘B’)
getPdfColor()
File: Lab.php line 200
public getPdfColor([bool $stroke = false ]) : string
Parameters
- $stroke : bool = false: True for stroking (lines, drawing) and false for non-stroking (text and area filling).
Return values
string
getRgbaHexColor()
File: Model.php line 409
public getRgbaHexColor() : string
Return values
string
getRgbHexColor()
File: Model.php line 434
public getRgbHexColor() : string
Return values
string
getType()
File: Model.php line 338
public getType() : string
Return values
string
getTypeEnum()
File: Model.php line 348
public getTypeEnum() : ColorModelType
Tags
- throws: Exception if the model declares an unknown type
Return values
invertColor()
File: Lab.php line 286
public invertColor() : static
Return values
static
toCmykArray()
File: Lab.php line 263
public toCmykArray() : array<string, float>
Return values
array<string, float> —
with keys (‘cyan’, ‘magenta’, ‘yellow’, ‘key’, ‘alpha’)
toGrayArray()
File: Lab.php line 210
public toGrayArray() : array<string, float>
Return values
array<string, float> —
with keys (‘gray’, ‘alpha’)
toHslArray()
File: Lab.php line 253
public toHslArray() : array<string, float>
Return values
array<string, float> —
with keys (‘hue’, ‘saturation’, ’lightness’, ‘alpha’)
toLabArray()
File: Lab.php line 273
public toLabArray() : array<string, float>
Return values
array<string, float> —
with keys (’lstar’, ‘astar’, ‘bstar’, ‘alpha’)
toRgbArray()
File: Lab.php line 220
public toRgbArray() : array<string, float>
Return values
array<string, float> —
with keys (‘red’, ‘green’, ‘blue’, ‘alpha’)
withInvertedColor()
File: Model.php line 426
public withInvertedColor() : static
The receiver is left untouched, unlike invertColor().
Return values
static