public function ColorRGB::__construct in Color Field 8.2
Create a new RGB color.
Parameters
int $red: The red (0-255)
int $green: The green (0-255)
int $blue: The blue (0-255)
float $opacity: The opacity.
Throws
Exception
File
- src/
ColorRGB.php, line 45
Class
- ColorRGB
- RGB represents the RGB color format.
Namespace
Drupal\color_fieldCode
public function __construct($red, $green, $blue, $opacity) {
if ($red < 0 || $red > 255) {
// @throws exception.
}
if ($green < 0 || $green > 255) {
// @throws exception.
}
if ($blue < 0 || $blue > 255) {
// @throws exception.
}
$this->red = $red;
$this->green = $green;
$this->blue = $blue;
$this->opacity = floatval($opacity);
}