public function ColorHSL::__construct in Color Field 8.2
Create a new HSL color.
Parameters
int $hue: The hue (0-360)
int $sat: The sat (0-100)
int $lum: The lum (0-100)
float $opacity: The opacity.
Throws
\Exception
File
- src/
ColorHSL.php, line 47
Class
- ColorHSL
- RGB represents the RGB color format.
Namespace
Drupal\color_fieldCode
public function __construct($hue, $sat, $lum, $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 = floatval($opacity);
}