src/Color.php
public function toHSV()
    {
        list($red, $green, $blue) = $this->toRGB();
        $red /= 255;
        $green /= 255;
        $blue /= 255;

        $maxRGB = max($red, $green, $blue);
        $minRGB = min($red, $green, $blue);
        $chroma = $maxRGB - $minRGB;

        $value = 100 * $maxRGB;

        if ($chroma == 0) {
            return [0, 0, $value];
        }

        $saturation = 100 * ($chroma / $maxRGB);

        if ($red == $minRGB) {
            $h = 3 - (($green - $blue) / $chroma);
        } elseif ($blue == $minRGB) {
            $h = 1 - (($red - $green) / $chroma);
        } else {
            $h = 5 - (($blue - $red) / $chroma);
        }

        $hue = 60 * $h;

        return [
            round($hue),
            round($saturation),
            round($value),
        ];
    }
public function toHSV()
    {
        list($red, $green, $blue) = $this->toRGB();
        $red /= 255;
        $green /= 255;
        $blue /= 255;

        $maxRGB = max($red, $green, $blue);
        $minRGB = min($red, $green, $blue);
        $chroma = $maxRGB - $minRGB;

        $value = 100 * $maxRGB;

        if ($chroma == 0) {
            return [0, 0, $value];
        }

        $saturation = 100 * ($chroma / $maxRGB);

        if ($red == $minRGB) {
            $h = 3 - (($green - $blue) / $chroma);
        } elseif ($blue == $minRGB) {
            $h = 1 - (($red - $green) / $chroma);
        } else {
            $h = 5 - (($blue - $red) / $chroma);
        }

        $hue = 60 * $h;

        return [
            round($hue),
            round($saturation),
            round($value),
        ];
    }
public function toHSV ( ) { list ( $ red , $ green , $ blue ) = $ this -> toRGB ( ) ; $ red /= 255 ; $ green /= 255 ; $ blue /= 255 ; $ maxRGB = max ( $ red , $ green , $ blue ) ; $ minRGB = min ( $ red , $ green , $ blue ) ; $ chroma = $ maxRGB - $ minRGB ; $ value = 100 * $ maxRGB ; if ( $ chroma == 0 ) { return [ 0 , 0 , $ value ] ; } $ saturation = 100 * ( $ chroma / $ maxRGB ) ; if ( $ red == $ minRGB ) { $ h = 3 - ( ( $ green - $ blue ) / $ chroma ) ; } elseif ( $ blue == $ minRGB ) { $ h = 1 - ( ( $ red - $ green ) / $ chroma ) ; } else { $ h = 5 - ( ( $ blue - $ red ) / $ chroma ) ; } $ hue = 60 * $ h ; return [ round ( $ hue ) , round ( $ saturation ) , round ( $ value ) , ] ; }
Outputs the color using the HSV format.

@return array HSV representation of the color
Outputs the color using the HSV format .