public static function fromHSL($h, $s, $l)
    {
        // theta plus 360 degrees
        $h -= floor($h);

        $c = new self();

        if ($s == 0) {
            $c->r = $c->g = $c->b = $l * 255;
            return $c;
        }

        $chroma = floatval(1 - abs(2*$l - 1)) * $s;

        // Divide $h by 60 degrees i.e by (60 / 360)
        $h_ = $h * 6;
        // intermediate
        $k = intval($h_);

        $h_mod2 = $k % 2 + $h_ - floor($h_);

        $x = $chroma * abs(1 - abs($h_mod2 - 1));

        $r = $g = $b = 0.0;

        switch ($k) {
        case 0: case 6:
            $r = $chroma;
            $g = $x;
            break;
        case 1:
            $r = $x;
            $g = $chroma;
            break;
        case 2:
            $g = $chroma;
            $b = $x;
            break;
        case 3:
            $g = $x;
            $b = $chroma;
            break;
        case 4:
            $r = $x;
            $b = $chroma;
            break;
        case 5:
            $r = $chroma;
            $b = $x;
            break;
        }

        $m = $l - 0.5 * $chroma;

        $c->r = (($r + $m) * 255);
        $c->g = (($g + $m) * 255);
        $c->b = (($b + $m) * 255);

        return $c;
    }
public static function fromHSL($h, $s, $l)
    {
        // theta plus 360 degrees
        $h -= floor($h);

        $c = new self();

        if ($s == 0) {
            $c->r = $c->g = $c->b = $l * 255;
            return $c;
        }

        $chroma = floatval(1 - abs(2*$l - 1)) * $s;

        // Divide $h by 60 degrees i.e by (60 / 360)
        $h_ = $h * 6;
        // intermediate
        $k = intval($h_);

        $h_mod2 = $k % 2 + $h_ - floor($h_);

        $x = $chroma * abs(1 - abs($h_mod2 - 1));

        $r = $g = $b = 0.0;

        switch ($k) {
        case 0: case 6:
            $r = $chroma;
            $g = $x;
            break;
        case 1:
            $r = $x;
            $g = $chroma;
            break;
        case 2:
            $g = $chroma;
            $b = $x;
            break;
        case 3:
            $g = $x;
            $b = $chroma;
            break;
        case 4:
            $r = $x;
            $b = $chroma;
            break;
        case 5:
            $r = $chroma;
            $b = $x;
            break;
        }

        $m = $l - 0.5 * $chroma;

        $c->r = (($r + $m) * 255);
        $c->g = (($g + $m) * 255);
        $c->b = (($b + $m) * 255);

        return $c;
    }
public static function fromHSL ( $ h , $ s , $ l ) { // theta plus 360 degrees $ h -= floor ( $ h ) ; $ c = new self ( ) ; if ( $ s == 0 ) { $ c -> r = $ c -> g = $ c -> b = $ l * 255 ; return $ c ; } $ chroma = floatval ( 1 - abs ( 2 * $ l - 1 ) ) * $ s ; // Divide $h by 60 degrees i.e by (60 / 360) $ h_ = $ h * 6 ; // intermediate $ k = intval ( $ h_ ) ; $ h_mod2 = $ k % 2 + $ h_ - floor ( $ h_ ) ; $ x = $ chroma * abs ( 1 - abs ( $ h_mod2 - 1 ) ) ; $ r = $ g = $ b = 0.0 ; switch ( $ k ) { case 0 : case 6 : $ r = $ chroma ; $ g = $ x ; break ; case 1 : $ r = $ x ; $ g = $ chroma ; break ; case 2 : $ g = $ chroma ; $ b = $ x ; break ; case 3 : $ g = $ x ; $ b = $ chroma ; break ; case 4 : $ r = $ x ; $ b = $ chroma ; break ; case 5 : $ r = $ chroma ; $ b = $ x ; break ; } $ m = $ l - 0.5 * $ chroma ; $ c -> r = ( ( $ r + $ m ) * 255 ) ; $ c -> g = ( ( $ g + $ m ) * 255 ) ; $ c -> b = ( ( $ b + $ m ) * 255 ) ; return $ c ; }
Construct a Color object from H, S, L values

@param float $h Hue
@param float $s Saturation
@param float $l Lightness

@retuns Color the color object for the HSL values
Construct a Color object from H S L values