Here you can find the source of hsvToRgb(double[] hsv)
Parameter | Description |
---|---|
v | The value |
public static int[] hsvToRgb(double[] hsv)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w . j a v a 2 s.c o m * Converts an HSV color value [0-1] to RGB [0-255]. * * @param Number h The hue * @param Number s The saturation * @param Number v The value * @return Array The RGB representation */ public static int[] hsvToRgb(double[] hsv) { double r = 0.0; double g = 0.0; double b = 0.0; double i = Math.floor(hsv[0] * 6.0); double f = hsv[0] * 6.0 - i; double p = hsv[2] * (1.0 - hsv[1]); double q = hsv[2] * (1.0 - f * hsv[1]); double t = hsv[2] * (1.0 - (1 - f) * hsv[1]); double c = i % 6; if (c == 0) { r = hsv[2]; g = t; b = p; } else if (c == 1) { r = q; g = hsv[2]; b = p; } else if (c == 2) { r = p; g = hsv[2]; b = t; } else if (c == 3) { r = p; g = q; b = hsv[2]; } else if (c == 4) { r = t; g = p; b = hsv[2]; } else if (c == 5) { r = hsv[2]; g = p; b = q; } return new int[] { (int) (r * 255.0), (int) (g * 255.0), (int) (b * 255.0) }; } }