public function toHSV()
    {
        // r, g, b as fractions of 1
        $r = $this->r / 255.0;
        $g = $this->g / 255.0;
        $b = $this->b / 255.0;

        // most prominent primary color
        $max = max($r, $g, $b);
        // least prominent primary color
        $min = min($r, $g, $b);
        // maximum delta
        $dmax = $max - $min;

        // value is just the fraction of
        // the most prominent primary color
        $v = $max;

        if ($dmax == 0) {
            // This means R=G=B, so:
            $h = 0;
            $s = 0;
        } else {
            $s = $dmax / $max;

            $dr = ((($max - $r) / 6) + ($dmax / 2)) / $dmax;
            $dg = ((($max - $g) / 6) + ($dmax / 2)) / $dmax;
            $db = ((($max - $b) / 6) + ($dmax / 2)) / $dmax;

            if ($r == $max) {
                $h = (0.0 / 3) + $db - $dg;
            } elseif ($g == $max) {
                $h = (1.0 / 3) + $dr - $db;
            } elseif ($b == $max) {
                $h = (2.0 / 3) + $dg - $dr;
            }

            // the case of less than 0 radians
            if ($h < 0) {
                $h += 1;
            }

            if ($h > 1) {
                $h -= 1;
            }
        }

        return array($h, $s, $v);
    }
public function toHSV()
    {
        // r, g, b as fractions of 1
        $r = $this->r / 255.0;
        $g = $this->g / 255.0;
        $b = $this->b / 255.0;

        // most prominent primary color
        $max = max($r, $g, $b);
        // least prominent primary color
        $min = min($r, $g, $b);
        // maximum delta
        $dmax = $max - $min;

        // value is just the fraction of
        // the most prominent primary color
        $v = $max;

        if ($dmax == 0) {
            // This means R=G=B, so:
            $h = 0;
            $s = 0;
        } else {
            $s = $dmax / $max;

            $dr = ((($max - $r) / 6) + ($dmax / 2)) / $dmax;
            $dg = ((($max - $g) / 6) + ($dmax / 2)) / $dmax;
            $db = ((($max - $b) / 6) + ($dmax / 2)) / $dmax;

            if ($r == $max) {
                $h = (0.0 / 3) + $db - $dg;
            } elseif ($g == $max) {
                $h = (1.0 / 3) + $dr - $db;
            } elseif ($b == $max) {
                $h = (2.0 / 3) + $dg - $dr;
            }

            // the case of less than 0 radians
            if ($h < 0) {
                $h += 1;
            }

            if ($h > 1) {
                $h -= 1;
            }
        }

        return array($h, $s, $v);
    }
public function toHSV ( ) { // r, g, b as fractions of 1 $ r = $ this -> r / 255.0 ; $ g = $ this -> g / 255.0 ; $ b = $ this -> b / 255.0 ; // most prominent primary color $ max = max ( $ r , $ g , $ b ) ; // least prominent primary color $ min = min ( $ r , $ g , $ b ) ; // maximum delta $ dmax = $ max - $ min ; // value is just the fraction of // the most prominent primary color $ v = $ max ; if ( $ dmax == 0 ) { // This means R=G=B, so: $ h = 0 ; $ s = 0 ; } else { $ s = $ dmax / $ max ; $ dr = ( ( ( $ max - $ r ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ dg = ( ( ( $ max - $ g ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ db = ( ( ( $ max - $ b ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; if ( $ r == $ max ) { $ h = ( 0.0 / 3 ) + $ db - $ dg ; } elseif ( $ g == $ max ) { $ h = ( 1.0 / 3 ) + $ dr - $ db ; } elseif ( $ b == $ max ) { $ h = ( 2.0 / 3 ) + $ dg - $ dr ; } // the case of less than 0 radians if ( $ h < 0 ) { $ h += 1 ; } if ( $ h > 1 ) { $ h -= 1 ; } } return array ( $ h , $ s , $ v ) ; }
Convert the current color to HSV values

@returns array An array with three elements: Hue, Saturation and Value.
Convert the current color to HSV values