Convert RGB color into HSV color

@param r red
@param g green
@param b blue
@param hsv (Output) HSV value.
976461
public static void rgbToHsv( float r , float g , float b , float []hsv ) {
		// Maximum value
		float max = r > g ? ( r > b ? r : b) : ( g > b ? g : b );
		// Minimum value
		float min = r < g ? ( r < b ? r : b) : ( g < b ? g : b );
		float delta = max - min;

		hsv[2] = max;

		if( max != 0 )
			hsv[1] = delta / max;
		else {
			hsv[0] = Float.NaN;
			hsv[1] = 0;
			return;
		}

		float h;
		if( r == max )
			h = ( g - b ) / delta;
		else if( g == max )
			h = 2 + ( b - r ) / delta;
		else
			h = 4 + ( r - g ) / delta;

		h *= d60_F32;
		if( h < 0 )
			h += PI2_F32;

		hsv[0] = h;
	}
463731
def set_draw_color(self, r,g=-1,b=-1):
        ""
        if((r==0 and g==0 and b==0) or g==-1):
            self.draw_color=sprintf('%.3f G',r/255.0)
        else:
            self.draw_color=sprintf('%.3f %.3f %.3f RG',r/255.0,g/255.0,b/255.0)
        if(self.page>0):
            self._out(self.draw_color)
849714
public static function rgb($red, $green, $blue)
    {
        self::throwIfInvalidColorComponentValue($red);
        self::throwIfInvalidColorComponentValue($green);
        self::throwIfInvalidColorComponentValue($blue);

        return strtoupper(
            self::convertColorComponentToHex($red) .
            self::convertColorComponentToHex($green) .
            self::convertColorComponentToHex($blue)
        );
    }
486402
public static Color HSVtoRGB (float h, float s, float v) {
		Color c = new Color(1, 1, 1, 1);
		HSVtoRGB(h, s, v, c);
		return c;
	}
994112
def colorRGB(r, g, b):
        
        return (float(r / 255), float(g / 255), float(b / 255))
1227698
public function toHTMLColor($R, $G, $B)
    {
        $R = intval($R);
        $G = intval($G);
        $B = intval($B);
        $R = dechex($R < 0 ? 0 : ($R > 255 ? 255 : $R));
        $G = dechex($G < 0 ? 0 : ($G > 255 ? 255 : $G));
        $B = dechex($B < 0 ? 0 : ($B > 255 ? 255 : $B));
        $Color = "#" . (strlen($R) < 2 ? '0' : '') . $R;
        $Color .= (strlen($G) < 2 ? '0' : '') . $G;
        $Color .= (strlen($B) < 2 ? '0' : '') . $B;

        return $Color;
    }
542756
public static function Rgb2Hex( $r, int $g = -1, int $b = -1 )
   {

      if ( \is_array( $r ) )
      {

         if ( \count( $r ) != 3 )
         {
            return false;
         }

         \array_change_key_case( $r, \CASE_LOWER );

         if ( isset( $r[ 'r' ] ) && isset( $r[ 'g' ] ) && isset( $r[ 'b' ] ) )
         {
            $g = $r[ 'g' ];
            $b = $r[ 'b' ];
            $r = $r[ 'r' ];
         }
         else if ( isset( $r[ 'red' ] ) && isset( $r[ 'green' ] ) && isset( $r[ 'blue' ] ) )
         {
            $g = $r[ 'green' ];
            $b = $r[ 'blue' ];
            $r = $r[ 'red' ];
         }
         else
         {
            $rgb = $r;
            list( $r, $g, $b ) = $rgb;
         }

      }
      else if ( \preg_match( '~^(rgb\s*\()?(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)?$~', (string) $r, $m ) )
      {

         list( $ignore, $r, $g, $b ) = $m;
         if ( ! empty( $ignore ) )
         {
            unset( $ignore );
         }

      }
      else if ( ! \is_int( $r ) )
      {

         return false;

      }
      $r1 = \intval( $r );
      $g1 = \intval( $g );
      $b1 = \intval( $b );
      $r  = \dechex( $r1 < 0 ? 0 : ( $r1 > 255 ? 255 : $r1 ) );
      $g  = \dechex( $g1 < 0 ? 0 : ( $g1 > 255 ? 255 : $g1 ) );
      $b  = \dechex( $b1 < 0 ? 0 : ( $b1 > 255 ? 255 : $b1 ) );

      return \sprintf( '#%02s%02s%02s', $r, $g, $b );

   }
390159
public static function rgb($r = 255, $g = 255, $b = 255)
    {
        // Check if values are in range.
        static::validateComp('R', $r, 0, 255);
        static::validateComp('G', $g, 0, 255);
        static::validateComp('B', $b, 0, 255);

        return new static($r, $g, $b);
    }
1356010
def hsv(self):
        
        r, g, b = self.color
        hsv = colorsys.rgb_to_hsv(r, g, b)
        hsv = (int(round(hsv[0] * 360)), hsv[1], hsv[2])
        return self._append_alpha_if_necessary(hsv)
364615
public static float[] getHSVArray(int r, int g, int b) {
        float[] hsv = new float[3];

        float rf = r / MAX;
        float gf = g / MAX;
        float bf = b / MAX;

        float minRGB = Math.min(rf, Math.min(gf, bf));
        float maxRGB = Math.max(rf, Math.max(gf, bf));

        float computedH = 0;
        float computedS = 0;
        float computedV = minRGB;

        // Black-gray-white
        if (minRGB != maxRGB) {
            // Colors other than black-gray-white:
            float d = (rf == minRGB) ? gf - bf : ((bf == minRGB) ? rf - gf : bf - rf);
            float h = (rf == minRGB) ? 3 : ((bf == minRGB) ? 1 : 5);
            computedH = 60 * (h - d / (maxRGB - minRGB));
            computedS = (maxRGB - minRGB) / maxRGB;
            computedV = maxRGB;
        }

        hsv[0] = computedH;
        hsv[1] = computedS;
        hsv[2] = computedV;
        return hsv;
    }
820400
function rgbToRgb(r, g, b){
    return {
        r: bound01(r, 255) * 255,
        g: bound01(g, 255) * 255,
        b: bound01(b, 255) * 255
    };
}
554948
private void RGBtoHSV(float red, float green, float blue) {

        float min = 0;
        float max = 0;
        float delta = 0;

        min = MIN(red, green, blue);
        max = MAX(red, green, blue);

        m_bri = max; // v

        delta = max - min;

        if (max != 0) {
            m_sat = delta / max; // s
        } else {
            m_sat = 0;
            m_hue = 0;
            return;
        }

        if (delta == 0) {
            m_hue = 0;
            return;
        }

        if (red == max) {
            m_hue = (green - blue) / delta;
        } else if (green == max) {
            m_hue = 2 + ((blue - red) / delta);
        } else {
            m_hue = 4 + ((red - green) / delta);
        }

        m_hue *= 60;

        if (m_hue < 0) {
            m_hue += 360;
        }
    }
1034959
def set_bg(self, r, g, b):
        
        self.img_bg = (r, g, b)
        self.redraw(whence=0)
714588
public static String toColor(String red, String green, String blue) {
		return toColorWithAlpha(red, green, blue, null);
	}
228927
public static int[] RGBtoHSV (float r, float g, float b) {
		float h, s, v;
		float min, max, delta;

		min = Math.min(Math.min(r, g), b);
		max = Math.max(Math.max(r, g), b);
		v = max;

		delta = max - min;

		if (max != 0)
			s = delta / max;
		else {
			s = 0;
			h = 0;
			return new int[]{MathUtils.round(h), MathUtils.round(s), MathUtils.round(v)};
		}

		if (delta == 0)
			h = 0;
		else {

			if (r == max)
				h = (g - b) / delta;
			else if (g == max)
				h = 2 + (b - r) / delta;
			else
				h = 4 + (r - g) / delta;
		}

		h *= 60;
		if (h < 0)
			h += 360;

		s *= 100;
		v *= 100;

		return new int[]{MathUtils.round(h), MathUtils.round(s), MathUtils.round(v)};
	}
65896
def rgb_offset(r, g, b)
      16 + (36 * scale_color(r)) + (6 * scale_color(g)) + scale_color(b)
    end
409447
def _rgba(r, g, b, a, **kwargs):
    
    return ColorValue((float(r), float(g), float(b), float(a)))