Here you can find the source of hslToRgb(double h, double s, double l)
public static double[] hslToRgb(double h, double s, double l)
//package com.java2s; //License from project: Open Source License public class Main { public static double[] hslToRgb(double h, double s, double l) { // Adapted from http://stackoverflow.com/a/9493060 double r; double g; double b; if (s == 0) { r = l;//w w w .ja va 2s.c o m g = l; b = l; } else { double q = l < 0.5 ? l * (1 + s) : l + s - l * s; double p = 2 * l - q; r = hue2Rgb(p, q, h + 1.0 / 3); g = hue2Rgb(p, q, h); b = hue2Rgb(p, q, h - 1.0 / 3); } return new double[] { r, g, b }; } private static double hue2Rgb(double p, double q, double t) { if (t < 0) t += 1; if (t > 1) t -= 1; if (t < 1.0 / 6) { return p + (q - p) * 6 * t; } if (t < 1.0 / 2) { return q; } if (t < 2.0 / 3) { return p + (q - p) * (2.0 / 3 - t) * 6; } return p; } }