Here you can find the source of hsvToRgb(float hue, float saturation, float value)
public static String hsvToRgb(float hue, float saturation, float value)
//package com.java2s; /*/* w w w.jav a2 s . co m*/ * Copyright 2011 gitblit.com. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { public static String hsvToRgb(float hue, float saturation, float value) { int h = (int) (hue * 6); float f = hue * 6 - h; float p = value * (1 - saturation); float q = value * (1 - f * saturation); float t = value * (1 - (1 - f) * saturation); switch (h) { case 0: return rgbToString(value, t, p); case 1: return rgbToString(q, value, p); case 2: return rgbToString(p, value, t); case 3: return rgbToString(p, q, value); case 4: return rgbToString(t, p, value); case 5: return rgbToString(value, p, q); default: throw new RuntimeException( "Something went wrong when converting from HSV to RGB. Input was " + hue + ", " + saturation + ", " + value); } } public static String rgbToString(float r, float g, float b) { String rs = Integer.toHexString((int) (r * 256)); String gs = Integer.toHexString((int) (g * 256)); String bs = Integer.toHexString((int) (b * 256)); return "#" + rs + gs + bs; } }