Rgb extends Model implements Template
Com\Tecnick\Color\Model\Rgb
RGB Color Model class
Tags
Interfaces, Classes and Traits
- Template
- Com\Tecnick\Color\Model\Template
Table of Contents
- $cmp_alpha : float
- Value of the Alpha channel component.
- $cmp_blue : float
- Value of the Blue color component [0..1]
- $cmp_green : float
- Value of the Green color component [0..1]
- $cmp_red : float
- Value of the Red color component [0..1]
- $type : string
- Color Model type
- __construct() : mixed
- Initialize a new color object
- getArray() : array<string|int, mixed>
- Get an array with all color components
- getComponentsString() : string
- Get a space separated string with color component values.
- getCssColor() : string
- Get the CSS representation of the color: rgba(R, G, B, A) NOTE: Supported since CSS3 and above.
- getHexValue() : int
- Get the normalized hexadecimal value of the specified float fraction
- getJsPdfColor() : string
- Get the color format used in Acrobat JavaScript NOTE: the alpha channel is omitted from this representation unless is 0 = transparent
- getNormalizedArray() : array<string|int, mixed>
- Get an array with color components values normalized between 0 and $max.
- getNormalizedValue() : int
- Get the normalized integer value of the specified float fraction
- getPdfColor() : string
- Get the color components format used in PDF documents (RGB) NOTE: the alpha channel is omitted
- getRgbaHexColor() : string
- Get the Hexadecimal representation of the color with alpha channel: #RRGGBBAA
- getRgbHexColor() : string
- Get the Hexadecimal representation of the color: #RRGGBB
- getType() : string
- Get the color model type (GRAY, RGB, HSL, CMYK)
- invertColor() : mixed
- Invert the color
- toCmykArray() : array<string|int, mixed>
- Get an array with CMYK color components
- toGrayArray() : array<string|int, mixed>
- Get an array with Gray color components
- toHslArray() : array<string|int, mixed>
- Get an array with HSL color components
- toRgbArray() : array<string|int, mixed>
- Get an array with RGB color components
Properties
$cmp_alpha
Value of the Alpha channel component.
protected float $cmp_alpha = 1.0
Values range between 0.0 (fully transparent) and 1.0 (fully opaque)
$cmp_blue
Value of the Blue color component [0..1]
protected float $cmp_blue = 0.0
$cmp_green
Value of the Green color component [0..1]
protected float $cmp_green = 0.0
$cmp_red
Value of the Red color component [0..1]
protected float $cmp_red = 0.0
$type
Color Model type
protected string $type = 'RGB'
Methods
__construct()
Initialize a new color object
public __construct(array<string|int,
mixed> $components)
: mixed
Parameters
- $components : array<string|int, mixed>
-
Array of color components is the range [0..1]
Return values
mixed —getArray()
Get an array with all color components
public getArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —with keys ('R', 'G', 'B', 'A')
getComponentsString()
Get a space separated string with color component values.
public getComponentsString()
: string
Return values
string —getCssColor()
Get the CSS representation of the color: rgba(R, G, B, A) NOTE: Supported since CSS3 and above.
public getCssColor()
: string
Use getHexadecimalColor() for CSS1 and CSS2
Return values
string —getHexValue()
Get the normalized hexadecimal value of the specified float fraction
public getHexValue(float $value,
int $max)
: int
Parameters
- $value : float
-
Fraction value to convert [0..1]
- $max : int
-
Maximum value to return (reference value)
Return values
int —value [0..$max]
getJsPdfColor()
Get the color format used in Acrobat JavaScript NOTE: the alpha channel is omitted from this representation unless is 0 = transparent
public getJsPdfColor()
: string
Return values
string —getNormalizedArray()
Get an array with color components values normalized between 0 and $max.
public getNormalizedArray(int $max)
: array<string|int,
mixed>
NOTE: the alpha and other fraction component values are kept in the [0..1] range.
Parameters
- $max : int
-
Maximum value to return (reference value)
Return values
array<string|int, mixed> —with keys ('R', 'G', 'B', 'A')
getNormalizedValue()
Get the normalized integer value of the specified float fraction
public getNormalizedValue(float $value,
int $max)
: int
Parameters
- $value : float
-
Fraction value to convert [0..1]
- $max : int
-
Maximum value to return (reference value)
Return values
int —value [0..$max]
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 = false
-
True for stroking (lines, drawing) and false for non-stroking (text and area filling).
Return values
string —getRgbaHexColor()
Get the Hexadecimal representation of the color with alpha channel: #RRGGBBAA
public getRgbaHexColor()
: string
Return values
string —getRgbHexColor()
Get the Hexadecimal representation of the color: #RRGGBB
public getRgbHexColor()
: string
Return values
string —getType()
Get the color model type (GRAY, RGB, HSL, CMYK)
public getType()
: string
Return values
string —invertColor()
Invert the color
public invertColor()
: mixed
Return values
mixed —toCmykArray()
Get an array with CMYK color components
public toCmykArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —with keys ('cyan', 'magenta', 'yellow', 'key', 'alpha')
toGrayArray()
Get an array with Gray color components
public toGrayArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —with keys ('gray')
toHslArray()
Get an array with HSL color components
public toHslArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —with keys ('hue', 'saturation', 'lightness', 'alpha')
toRgbArray()
Get an array with RGB color components
public toRgbArray()
: array<string|int,
mixed>
Return values
array<string|int, mixed> —with keys ('red', 'green', 'blue', 'alpha')