Table of contents
Namespace: Com\Tecnick\Color\Model
class Rgb extends Model
Extends: Model
Source: src/Model/Rgb.php:34
RGB Color Model class
Methods
__construct()
Initialize a new RGB color object.
public __construct(array<string,int|float|string> $components)
Parameters:
$components(array<string,int|float|string>): Color components, each clamped to [0..1].
Throws:
- UnknownComponentException: if a component name is not defined by this model
Source: src/Model/Rgb.php:63
getArray()
Get an array with all color components.
public getArray(): array<string,float>
Returns: array<string,float>: with keys (‘R’, ‘G’, ‘B’, ‘A’)
Source: src/Model/Rgb.php:77
getComponentsString()
Get a space separated string with color component values.
public getComponentsString(): string
Returns: string
Source: src/Model/Rgb.php:167
getCssColor()
Get the CSS representation of the color: rgb(R, G, B) or rgba(R, G, B, A)
Channels are emitted as integers in [0..255].
public getCssColor(): string
Returns: string
Source: src/Model/Rgb.php:129
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/Rgb.php:155
getNormalizedArray()
Get an array with color components values normalized between 0 and $max.
NOTE: the alpha and other fraction component values are kept in the [0..1] range.
public getNormalizedArray(int $max): array<string,float>
Parameters:
$max(int): Maximum value to return (reference value)
Returns: array<string,float>: with keys (‘R’, ‘G’, ‘B’, ‘A’)
Source: src/Model/Rgb.php:114
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/Rgb.php:97
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/Rgb.php:178
invertColor()
Invert the color
public invertColor(): static
Returns: static
Source: src/Model/Rgb.php:241
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/Rgb.php:223
toGrayArray()
Get an array with Gray color components
public toGrayArray(): array<string,float>
Returns: array<string,float>: with keys (‘gray’, ‘alpha’)
Source: src/Model/Rgb.php:188
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/Rgb.php:213
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/Rgb.php:233
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/Rgb.php:198
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.