Here you can find the source of HslToRgb(float h, float s, float l, float a)
static float[] HslToRgb(float h, float s, float l, float a)
//package com.java2s; //License from project: Apache License public class Main { static float[] HslToRgb(float h, float s, float l, float a) { float[] result = new float[4]; if (s == 0) { result[0] = l;/*from www.java 2s .c om*/ result[1] = l; result[2] = l; result[3] = a; } else { float q = (l < 0.5f) ? (l * (1.0f + s)) : (l + s - (l * s)); float p = (2.0f * l) - q; float[] T = new float[3]; T[0] = h + (1.0f / 3.0f); // Tr T[1] = h; // Tb T[2] = h - (1.0f / 3.0f); // Tg for (int i = 0; i < 3; i++) { if (T[i] < 0) T[i] += 1.0; if (T[i] > 1) T[i] -= 1.0; if ((T[i] * 6) < 1) { T[i] = p + ((q - p) * 6.0f * T[i]); } else if ((T[i] * 2.0f) < 1) { T[i] = q; } else if ((T[i] * 3.0f) < 2) { T[i] = p + (q - p) * ((2.0f / 3.0f) - T[i]) * 6.0f; } else T[i] = p; } result[0] = T[0]; result[1] = T[1]; result[2] = T[2]; result[3] = a; } return result; } }