public static function rgbToHsl($red, $green, $blue)
    {
        if (\min($red, $green, $blue) < 0) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no less than 0');
        }

        if (\max($red, $green, $blue) > 0xFF) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no more than 255');
        }

        $clrMin = \min($red, $green, $blue);
        $clrMax = \max($red, $green, $blue);
        $deltaMax = $clrMax - $clrMin;

        $L = ($clrMax + $clrMin) / 510;

        if (0 == $deltaMax) {
            $H = 0;
            $S = 0;
        } else {
            if (0.5 > $L) {
                $S = $deltaMax / ($clrMax + $clrMin);
            } else {
                $S = $deltaMax / (510 - $clrMax - $clrMin);
            }

            if ($clrMax === $red) {
                $H = ($green - $blue) / (6.0 * $deltaMax);

                if (0 > $H) {
                    $H += 1.0;
                }
            } elseif ($clrMax === $green) {
                $H = 1 / 3 + ($blue - $red) / (6.0 * $deltaMax);
            } else {
                $H = 2 / 3 + ($red - $green) / (6.0 * $deltaMax);
            }
        }

        return array(
            (float) ($H * 360 % 360),
            (float) ($S * 100),
            (float) ($L * 100),
        );
    }
public static function rgbToHsl($red, $green, $blue)
    {
        if (\min($red, $green, $blue) < 0) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no less than 0');
        }

        if (\max($red, $green, $blue) > 0xFF) {
            throw new InvalidArgumentException('The parameters for rgbToHsl should be no more than 255');
        }

        $clrMin = \min($red, $green, $blue);
        $clrMax = \max($red, $green, $blue);
        $deltaMax = $clrMax - $clrMin;

        $L = ($clrMax + $clrMin) / 510;

        if (0 == $deltaMax) {
            $H = 0;
            $S = 0;
        } else {
            if (0.5 > $L) {
                $S = $deltaMax / ($clrMax + $clrMin);
            } else {
                $S = $deltaMax / (510 - $clrMax - $clrMin);
            }

            if ($clrMax === $red) {
                $H = ($green - $blue) / (6.0 * $deltaMax);

                if (0 > $H) {
                    $H += 1.0;
                }
            } elseif ($clrMax === $green) {
                $H = 1 / 3 + ($blue - $red) / (6.0 * $deltaMax);
            } else {
                $H = 2 / 3 + ($red - $green) / (6.0 * $deltaMax);
            }
        }

        return array(
            (float) ($H * 360 % 360),
            (float) ($S * 100),
            (float) ($L * 100),
        );
    }
public static function rgbToHsl ( $ red , $ green , $ blue ) { if ( \ min ( $ red , $ green , $ blue ) < 0 ) { throw new InvalidArgumentException ( 'The parameters for rgbToHsl should be no less than 0' ) ; } if ( \ max ( $ red , $ green , $ blue ) > 0xFF ) { throw new InvalidArgumentException ( 'The parameters for rgbToHsl should be no more than 255' ) ; } $ clrMin = \ min ( $ red , $ green , $ blue ) ; $ clrMax = \ max ( $ red , $ green , $ blue ) ; $ deltaMax = $ clrMax - $ clrMin ; $ L = ( $ clrMax + $ clrMin ) / 510 ; if ( 0 == $ deltaMax ) { $ H = 0 ; $ S = 0 ; } else { if ( 0.5 > $ L ) { $ S = $ deltaMax / ( $ clrMax + $ clrMin ) ; } else { $ S = $ deltaMax / ( 510 - $ clrMax - $ clrMin ) ; } if ( $ clrMax === $ red ) { $ H = ( $ green - $ blue ) / ( 6.0 * $ deltaMax ) ; if ( 0 > $ H ) { $ H += 1.0 ; } } elseif ( $ clrMax === $ green ) { $ H = 1 / 3 + ( $ blue - $ red ) / ( 6.0 * $ deltaMax ) ; } else { $ H = 2 / 3 + ( $ red - $ green ) / ( 6.0 * $ deltaMax ) ; } } return array ( ( float ) ( $ H * 360 % 360 ) , ( float ) ( $ S * 100 ) , ( float ) ( $ L * 100 ) , ) ; }
Converts RGB to HSL. Color inversion of previous black magic is white magic?

@param float|int $red   Red
@param float|int $green Green
@param float|int $blue  Blue

@return float[] HSL array
Converts RGB to HSL . Color inversion of previous black magic is white magic?