Here you can find the source of hslToRgb(double hue, double sat, double lum)
private static byte[] hslToRgb(double hue, double sat, double lum)
//package com.java2s; public class Main { private static byte[] hslToRgb(double hue, double sat, double lum) { double r, g, b; if (sat == 0d) { r = g = b = lum; // gray scale } else {//from www . ja va 2 s . com final double q = lum < 0.5d ? lum * (1d + sat) : lum + sat - lum * sat; final double p = 2d * lum - q; r = hue2rgb(p, q, hue + 1d / 3d); g = hue2rgb(p, q, hue); b = hue2rgb(p, q, hue - 1d / 3d); } final byte red = (byte) (r * 255d); final byte green = (byte) (g * 255d); final byte blue = (byte) (b * 255d); return new byte[] { red, green, blue }; } private static double hue2rgb(double p, double q, double t) { if (t < 0d) t += 1d; if (t > 1d) t -= 1d; if (t < 1d / 6d) return p + (q - p) * 6d * t; if (t < 1d / 2d) return q; if (t < 2d / 3d) return p + (q - p) * (2d / 3d - t) * 6d; return p; } }