Same name in other branches
- 8.x-2.x src/ColorHSL.php \Drupal\color_field\ColorHSL::__construct()
Create a new HSL color.
Paramètres
int $hue: The hue (0-360)
int $sat: The sat (0-100)
int $lum: The lum (0-100)
float $opacity: The opacity.
Throws
\Exception
Fichier
-
src/
ColorHSL.php, line 47
Classe
- ColorHSL
- RGB represents the RGB color format.
Namespace
Drupal\color_fieldCode
public function __construct(int $hue, int $sat, int $lum, float $opacity) {
if ($hue < 0 || $hue > 360) {
throw new \Exception("Invalid hue: {$hue}");
}
if ($sat < 0 || $sat > 100) {
throw new \Exception("Invalid saturation: {$sat}");
}
if ($lum < 0 || $lum > 100) {
throw new \Exception("Invalid luminosity: {$lum}");
}
$this->hue = $hue;
$this->sat = $sat;
$this->lum = $lum;
$this->opacity = $opacity;
}