Java examples for 2D Graphics:Color RGB
hsv To Rgb
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { float hue = 2.45678f; float saturation = 2.45678f; float value = 2.45678f; System.out.println(java.util.Arrays.toString(hsvToRgb(hue, saturation, value)));//from www . j a v a 2 s .c o m } public static float[] 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 new float[] { value, t, p }; case 1: return new float[] { value, t, p }; case 2: return new float[] { p, value, t }; case 3: return new float[] { p, q, value }; case 4: return new float[] { t, p, value }; case 5: return new float[] { value, p, q }; default: } return new float[3]; } }