src/Alg/ColorConverter.php
public static function rgb2hsv( $rgb )
	{
#		return self::rgb2hsv_2( $rgb );
		list( $r, $g, $b ) = $rgb;
		$v	= max( $r, $g, $b );
		$t	= min( $r, $g, $b );
		$s	= ( $v == 0 ) ? 0 : ( $v - $t ) / $v;
		if( $s == 0 )
			$h	= 0;
		else
		{
			$a	= $v - $t;
			$cr	= ( $v - $r ) / $a;
			$cg	= ( $v - $g ) / $a;
			$cb	= ( $v - $b ) / $a;
			$h	= ( $r == $v ) ? $cb - $cg : ( ( $g == $v ) ? 2 + $cr - $cb : ( ( $b == $v ) ? $h = 4 + $cg - $cr : 0 ) );
			$h	= 60 * $h;
			$h	= ( $h < 0 ) ? $h + 360 : $h;
		}
		return array( round( $h ), round( $s * 100 ), round( $v / 2.55 ) );
	}
public static function rgb2hsv( $rgb )
	{
#		return self::rgb2hsv_2( $rgb );
		list( $r, $g, $b ) = $rgb;
		$v	= max( $r, $g, $b );
		$t	= min( $r, $g, $b );
		$s	= ( $v == 0 ) ? 0 : ( $v - $t ) / $v;
		if( $s == 0 )
			$h	= 0;
		else
		{
			$a	= $v - $t;
			$cr	= ( $v - $r ) / $a;
			$cg	= ( $v - $g ) / $a;
			$cb	= ( $v - $b ) / $a;
			$h	= ( $r == $v ) ? $cb - $cg : ( ( $g == $v ) ? 2 + $cr - $cb : ( ( $b == $v ) ? $h = 4 + $cg - $cr : 0 ) );
			$h	= 60 * $h;
			$h	= ( $h < 0 ) ? $h + 360 : $h;
		}
		return array( round( $h ), round( $s * 100 ), round( $v / 2.55 ) );
	}
public static function rgb2hsv ( $ rgb ) { #		return self::rgb2hsv_2( $rgb );
 list ( $ r , $ g , $ b ) = $ rgb ; $ v = max ( $ r , $ g , $ b ) ; $ t = min ( $ r , $ g , $ b ) ; $ s = ( $ v == 0 ) ? 0 : ( $ v - $ t ) / $ v ; if ( $ s == 0 ) $ h = 0 ; else { $ a = $ v - $ t ; $ cr = ( $ v - $ r ) / $ a ; $ cg = ( $ v - $ g ) / $ a ; $ cb = ( $ v - $ b ) / $ a ; $ h = ( $ r == $ v ) ? $ cb - $ cg : ( ( $ g == $ v ) ? 2 + $ cr - $ cb : ( ( $ b == $ v ) ? $ h = 4 + $ cg - $ cr : 0 ) ) ; $ h = 60 * $ h ; $ h = ( $ h < 0 ) ? $ h + 360 : $ h ; } return array ( round ( $ h ) , round ( $ s * 100 ) , round ( $ v / 2.55 ) ) ; }
Converts RGB to HSV.
@access		public
@static
@param		array	rgb		RGB-Color as array
@return		array
Converts RGB to HSV .