Hsl

HSL Color Model class

Namespace: Com\Tecnick\Color\Model

Extends: Model

File: Hsl.php line 34

HSL Color Model class

Tags

Methods

__construct()

File: Hsl.php line 66

public __construct(array<string, int|float|string> $components) : mixed

Saturation, lightness and alpha are clamped to [0..1]. Hue is a fraction of a full turn and wraps into [0..1) instead.

Parameters

  • $components : array<string, int|float|string>: Color components.

Tags

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

Return values

self

getArray()

File: Hsl.php line 80

public getArray() : array<string, float>

Return values

array<string, float> —

with keys (‘H’, ‘S’, ‘L’, ‘A’)

getComponentsString()

File: Hsl.php line 177

public getComponentsString() : string

Return values

string

getCssColor()

File: Hsl.php line 137

public getCssColor() : string

Hue is in degrees, saturation and lightness are percentages, all emitted 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: Hsl.php line 164

public getJsPdfColor() : string

Return values

string

getNormalizedArray()

File: Hsl.php line 121

public getNormalizedArray(int $max) : array<string, float>

NOTE: the $max argument is not applied here. Hue is returned in degrees [0..360], while saturation, lightness and alpha are fraction components kept in the [0..1] range.

Parameters

  • $max : int: Unused; kept for interface compatibility.

Return values

array<string, float> —

with keys (‘H’, ‘S’, ‘L’, ‘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: Hsl.php line 100

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: Hsl.php line 188

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

ColorModelType

invertColor()

File: Hsl.php line 305

public invertColor() : static

Inversion is the RGB complement (1 - component), computed through RGB.

Return values

static

toCmykArray()

File: Hsl.php line 285

public toCmykArray() : array<string, float>

Return values

array<string, float> —

with keys (‘cyan’, ‘magenta’, ‘yellow’, ‘key’, ‘alpha’)

toGrayArray()

File: Hsl.php line 198

public toGrayArray() : array<string, float>

Return values

array<string, float> —

with keys (‘gray’, ‘alpha’)

toHslArray()

File: Hsl.php line 270

public toHslArray() : array<string, float>

Return values

array<string, float> —

with keys (‘hue’, ‘saturation’, ’lightness’, ‘alpha’)

toLabArray()

File: Hsl.php line 295

public toLabArray() : array<string, float>

Return values

array<string, float> —

with keys (’lstar’, ‘astar’, ‘bstar’, ‘alpha’)

toRgbArray()

File: Hsl.php line 208

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