Hsl

HSL Color Model class

Namespace: Com\Tecnick\Color\Model

class Hsl extends Model

Extends: Model

Source: src/Model/Hsl.php:34

HSL Color Model class

Methods

__construct()

Initialize a new HSL color object.

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

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

Parameters:

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

Throws:

Source: src/Model/Hsl.php:66

getArray()

Get an array with all color components.

public getArray(): array<string,float>

Returns: array<string,float>: with keys (‘H’, ‘S’, ‘L’, ‘A’)

Source: src/Model/Hsl.php:80

getComponentsString()

Get a space separated string with color component values.

public getComponentsString(): string

Returns: string

Source: src/Model/Hsl.php:177

getCssColor()

Get the CSS representation of the color: hsl(H, S, L) or hsla(H, S, L, A)

Hue is in degrees, saturation and lightness are percentages, all emitted with up to 4 decimals.

public getCssColor(): string

Returns: string

Source: src/Model/Hsl.php:137

getJsPdfColor()

Get the color format used in Acrobat JavaScript NOTE: the alpha channel is omitted from this representation unless it is 0 = transparent

public getJsPdfColor(): string

Returns: string

Source: src/Model/Hsl.php:164

getNormalizedArray()

Get an array with color components values normalized.

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.

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

Parameters:

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

Returns: array<string,float>: with keys (‘H’, ‘S’, ‘L’, ‘A’)

Source: src/Model/Hsl.php:121

getPDFacArray()

Get an array with all color components for the PDF appearance characteristics dictionary.

The values are in the range 0.0 to 1.0 and the number of array elements determines the color space: 3 = DeviceRGB

public getPDFacArray(): float[]

Returns: float[]: DeviceRGB color components (‘R’, ‘G’, ‘B’)

Source: src/Model/Hsl.php:100

getPdfColor()

Get the color components format used in PDF documents (RGB) NOTE: the alpha channel is omitted

public getPdfColor(bool $stroke = false): string

Parameters:

  • $stroke (bool): True for stroking (lines, drawing) and false for non-stroking (text and area filling).

Returns: string

Source: src/Model/Hsl.php:188

invertColor()

Invert the color.

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

public invertColor(): static

Returns: static

Source: src/Model/Hsl.php:305

toCmykArray()

Get an array with CMYK color components

public toCmykArray(): array<string,float>

Returns: array<string,float>: with keys (‘cyan’, ‘magenta’, ‘yellow’, ‘key’, ‘alpha’)

Source: src/Model/Hsl.php:285

toGrayArray()

Get an array with Gray color components

public toGrayArray(): array<string,float>

Returns: array<string,float>: with keys (‘gray’, ‘alpha’)

Source: src/Model/Hsl.php:198

toHslArray()

Get an array with HSL color components

public toHslArray(): array<string,float>

Returns: array<string,float>: with keys (‘hue’, ‘saturation’, ’lightness’, ‘alpha’)

Source: src/Model/Hsl.php:270

toLabArray()

Get an array with Lab color components

public toLabArray(): array<string,float>

Returns: array<string,float>: with keys (’lstar’, ‘astar’, ‘bstar’, ‘alpha’)

Source: src/Model/Hsl.php:295

toRgbArray()

Get an array with RGB color components

public toRgbArray(): array<string,float>

Returns: array<string,float>: with keys (‘red’, ‘green’, ‘blue’, ‘alpha’)

Source: src/Model/Hsl.php:208

Inherited members

From Model

  • create(): Create a color model instance of the given type.
  • getHexValue(): Get the normalized hexadecimal value of the specified float fraction
  • getNormalizedValue(): Get the normalized integer value of the specified float fraction
  • getRgbaHexColor(): Get the Hexadecimal representation of the color with alpha channel: #RRGGBBAA
  • getRgbHexColor(): Get the Hexadecimal representation of the color: #RRGGBB
  • getType(): Get the color model type (GRAY, RGB, HSL, CMYK, LAB)
  • getTypeEnum(): Get the color model type as a backed enum case.
  • withInvertedColor(): Get a copy of the color, inverted.