Same name and namespace in other branches
  1. 8.x-2.x src/ColorHSL.php \Drupal\color_field\ColorHSL::__construct() 1 comment

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_field

Code

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;
}