Table of contents
Namespace: Com\Tecnick\Color
abstract class Model implements Template
Implements: Template
Source: src/Model.php:36
Color Model class
Methods
create()
Create a color model instance of the given type.
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.
Returns: self
Throws:
- Exception: if the type is unknown
- UnknownComponentException: if a component name is not defined by the model
Source: src/Model.php:76
getHexValue()
Get the normalized hexadecimal value of the specified float fraction
The result is zero-padded to 2 digits.
public getHexValue(float $value, int $max): string
Parameters:
$value(float): Fraction value to convert [0..1]$max(int): Maximum value to return (reference value) [0..255]
Returns: string
Source: src/Model.php:401
getNormalizedValue()
Get the normalized integer value of the specified float fraction
public getNormalizedValue(float $value, int $max): float
Parameters:
$value(float): Fraction value to convert [0..1]$max(int): Maximum value to return (reference value)
Returns: float: value [0..$max]
Source: src/Model.php:361
getRgbaHexColor()
Get the Hexadecimal representation of the color with alpha channel: #RRGGBBAA
public getRgbaHexColor(): string
Returns: string
Source: src/Model.php:409
getRgbHexColor()
Get the Hexadecimal representation of the color: #RRGGBB
public getRgbHexColor(): string
Returns: string
Source: src/Model.php:434
getType()
Get the color model type (GRAY, RGB, HSL, CMYK, LAB)
public getType(): string
Returns: string
Source: src/Model.php:338
getTypeEnum()
Get the color model type as a backed enum case.
public getTypeEnum(): ColorModelType
Returns: ColorModelType
Throws:
- Exception: if the model declares an unknown type
Source: src/Model.php:348
withInvertedColor()
Get a copy of the color, inverted.
The receiver is left untouched, unlike invertColor().
public withInvertedColor(): static
Returns: static
Source: src/Model.php:426