Converts the RGB into the HSV.<p>
@param red value
@param green value
@param blue value
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;
        }
    }
1134271
private function setValues($red, $green, $blue)
    {
        if ( ! $this->checkRgbValues($red, $green, $blue) ) {
            throw new Exceptions\InvalidRGBValuesException("Incorrect RGB Values (red = {$red}, green = {$green}, blue = {$blue}).");
        }

        $this->setRed($red);
        $this->setGreen($green);
        $this->setBlue($blue);
    }
742550
private int getPressedColor(int color) {
        float[] hsv = new float[3];
        Color.colorToHSV(color, hsv);
        hsv[2] = hsv[2] * PRESSED_STATE_MULTIPLIER;
        return Color.HSVToColor(hsv);
    }
1285658
static HSV toHSV( double color ) {
        long argb = Double.doubleToRawLongBits( color );
        double a = alpha( color );
        double r = clamp( ((argb >> 32) & 0xFFFF) / (double)0xFF00 );
        double g = clamp( ((argb >> 16) & 0xFFFF) / (double)0xFF00 );
        double b = clamp( ((argb >> 0) & 0xFFFF) / (double)0xFF00 );

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

        double d = max - min;
        if (max == 0) {
            s = 0;
        } else {
            s = d / max;
        }

        if (max == min) {
            h = 0;
        } else if( max == r ){
            h = (g - b) / d + (g < b ? 6 : 0);
        } else if( max == g ){
            h = (b - r) / d + 2;
        } else { //if( max == b ){
            h = (r - g) / d + 4;
        }
        h /= 6;
        return new HSV( h * 360, s, v,  a );
    }
940688
public Color getFromRGB(final int red, final int green, final int blue) {
        return this.getFromString("#" + this.toHexString(red) + this.toHexString(green) + this
                        .toHexString(blue));
    }
57300
def set_color_hsv(self, hue, saturation, value):
        """"""
        try:
            data = "action=on&color={};{};{}".format(hue, saturation, value)
            request = requests.post(
                '{}/{}/{}'.format(self.resource, URI, self._mac),
                data=data, timeout=self.timeout)
            if request.status_code == 200:
                self.data['on'] = True
        except requests.exceptions.ConnectionError:
            raise exceptions.MyStromConnectionError()
20133
private static int toAnsi(int red, int green, int blue)
    {
        // rescale to 0-5 range
        red = red * 6 / 256;
        green = green * 6 / 256;
        blue = blue * 6 / 256;

        return 16 + red * 36 + green * 6 + blue;
    }
316591
public static Color rgbToColorConverter(final String value) {

        if (StringUtils.isEmpty(value) || (!StringUtils.isEmpty(value) && !value.startsWith("rgb"))) {
            throw new IllegalArgumentException(
                    "String to convert is empty or of invalid format - value: '" + value + "'");
        }

        // RGB color format rgb/rgba(255,255,255,0.1)
        final String[] colors = value.substring(value.indexOf('(') + 1, value.length() - 1).split(",");
        final int red = Integer.parseInt(colors[0]);
        final int green = Integer.parseInt(colors[1]);
        final int blue = Integer.parseInt(colors[2]);
        if (colors.length > 3) {
            final int alpha = (int) (Double.parseDouble(colors[3]) * 255D);
            return new Color(red, green, blue, alpha);
        }
        return new Color(red, green, blue);
    }
78326
public void setDiffuse(float red, float green, float blue){
        diffuse[0] = red;
        diffuse[1] = green;
        diffuse[2] = blue;
        Di = true;
    }
927372
public function color($red, $green, $blue)
    {
        $this->writer->getRenderer()->setForegroundColor(new Rgb($red, $green, $blue));

        return $this;
    }
935354
public static Color HSVtoRGB (float h, float s, float v, float alpha) {
		Color c = HSVtoRGB(h, s, v);
		c.a = alpha;
		return c;
	}
852146
public void setRGB(int red, int green, int blue) throws Exception {

        if ((red < 0) || (red > 255)) {
            throw new Exception();
        }
        if ((green < 0) || (green > 255)) {
            throw new Exception();
        }
        if ((blue < 0) || (blue > 255)) {
            throw new Exception();
        }

        m_red = (float)red / 255;
        m_green = (float)green / 255;
        m_blue = (float)blue / 255;

        RGBtoHSV(m_red, m_green, m_blue);

        setHex();
    }
1289303
public void setColor(String red, String green, String blue, String alpha) {
		setColor(red, green, blue);
		setAlpha(alpha);
	}
259292
def _hsv_to_rgb(hsvs):
    """"""
    hsvs, n_dim = _check_color_dim(hsvs)
    # In principle, we *might* be able to vectorize this, but might as well
    # wait until a compelling use case appears
    rgbs = list()
    for hsv in hsvs:
        c = hsv[1] * hsv[2]
        m = hsv[2] - c
        hp = hsv[0] / 60
        x = c * (1 - abs(hp % 2 - 1))
        if 0 <= hp < 1:
            r, g, b = c, x, 0
        elif hp < 2:
            r, g, b = x, c, 0
        elif hp < 3:
            r, g, b = 0, c, x
        elif hp < 4:
            r, g, b = 0, x, c
        elif hp < 5:
            r, g, b = x, 0, c
        else:
            r, g, b = c, 0, x
        rgb = [r + m, g + m, b + m]
        rgbs.append(rgb)
    rgbs = np.array(rgbs, dtype=np.float32)
    if n_dim == 4:
        rgbs = np.concatenate((rgbs, hsvs[:, 3]), axis=1)
    return rgbs
643895
public static Color[] heat(int n, float alpha) {
        int j = n / 4;
        int k = n - j;
        float h = 1.0f / 6;

        Color[] c = rainbow(k, 0, h, alpha);

        Color[] palette = new Color[n];
        System.arraycopy(c, 0, palette, 0, k);

        float s = 1 - 1.0f / (2 * j);
        float end = 1.0f / (2 * j);
        float w = (end - s) / (j - 1);

        for (int i = k; i < n; i++) {
            palette[i] = hsv(h, s, 1.0f, alpha);
            s += w;
        }

        return palette;
    }
484720
public static java.awt.Color convertColor(cz.vutbr.web.csskit.Color src)
    {
        return new java.awt.Color(src.getRGB(), true);
    }
1205962
def colour_hsv(self):
        """"""
        hexvalue = self.status()[self.DPS][self.DPS_INDEX_COLOUR]
        return BulbDevice._hexvalue_to_hsv(hexvalue)