src/Marando/Color/Color.php
private static function rgb2hsl($r, $g, $b, &$h, &$s, &$l)
    {
        $r /= 255;
        $g /= 255;
        $b /= 255;

        $min = min([$r, $g, $b]);
        $max = max([$r, $g, $b]);

        $l = ($min + $max) / 2;
        $l = round($l, 2);

        if ($min == $max) {
            $s = 0;
            $h = 0;

            return;
        }

        if ($l < 0.5) {
            $s = ($max - $min) / ($max + $min);
        } else {
            $s = ($max - $min) / (2.0 - $max - $min);
        }

        if ($r == $max) {
            $h = ($g - $b) / ($max - $min);
        } elseif ($g == $max) {
            $h = 2.0 + ($b - $r) / ($max - $min);
        } else {
            $h = 4.0 + ($r - $g) / ($max - $min);
        }

        $h *= 60;
        $h = $h < 0 ? $h + 360 : $h;
        $h = (int)round($h);

        $s = round($s, 2);
    }
private static function rgb2hsl($r, $g, $b, &$h, &$s, &$l)
    {
        $r /= 255;
        $g /= 255;
        $b /= 255;

        $min = min([$r, $g, $b]);
        $max = max([$r, $g, $b]);

        $l = ($min + $max) / 2;
        $l = round($l, 2);

        if ($min == $max) {
            $s = 0;
            $h = 0;

            return;
        }

        if ($l < 0.5) {
            $s = ($max - $min) / ($max + $min);
        } else {
            $s = ($max - $min) / (2.0 - $max - $min);
        }

        if ($r == $max) {
            $h = ($g - $b) / ($max - $min);
        } elseif ($g == $max) {
            $h = 2.0 + ($b - $r) / ($max - $min);
        } else {
            $h = 4.0 + ($r - $g) / ($max - $min);
        }

        $h *= 60;
        $h = $h < 0 ? $h + 360 : $h;
        $h = (int)round($h);

        $s = round($s, 2);
    }
private static function rgb2hsl ( $ r , $ g , $ b , & $ h , & $ s , & $ l ) { $ r /= 255 ; $ g /= 255 ; $ b /= 255 ; $ min = min ( [ $ r , $ g , $ b ] ) ; $ max = max ( [ $ r , $ g , $ b ] ) ; $ l = ( $ min + $ max ) / 2 ; $ l = round ( $ l , 2 ) ; if ( $ min == $ max ) { $ s = 0 ; $ h = 0 ; return ; } if ( $ l < 0.5 ) { $ s = ( $ max - $ min ) / ( $ max + $ min ) ; } else { $ s = ( $ max - $ min ) / ( 2.0 - $ max - $ min ) ; } if ( $ r == $ max ) { $ h = ( $ g - $ b ) / ( $ max - $ min ) ; } elseif ( $ g == $ max ) { $ h = 2.0 + ( $ b - $ r ) / ( $ max - $ min ) ; } else { $ h = 4.0 + ( $ r - $ g ) / ( $ max - $ min ) ; } $ h *= 60 ; $ h = $ h < 0 ? $ h + 360 : $ h ; $ h = ( int ) round ( $ h ) ; $ s = round ( $ s , 2 ) ; }
Converts RGB to HSL.

@param $r Red, 0-255
@param $g Green, 0-255
@param $b Blue, 0-255
@param $h Hue, 0-360°
@param $s Saturation, 0-1
@param $l Lightness, 0-1
Converts RGB to HSL .