Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Color; public class Main { private static int hslToRgb(float hsl[]) { float h = hsl[0] / 360.f; float s = hsl[1]; float l = hsl[2]; int r; int g; int b; if (s == 0) { r = g = b = (int) (l * 255f); } else { float t1 = l < 0.5 ? l * (1 + s) : l + s - l * s; float t2 = 2 * l - t1; r = (int) (hueToMagnitude(t1, t2, h + 1 / 3f) * 255f); g = (int) (hueToMagnitude(t1, t2, h) * 255f); b = (int) (hueToMagnitude(t1, t2, h - 1 / 3f) * 255f); } return Color.rgb(r, g, b); } private static float hueToMagnitude(float t1, float t2, float h) { h += h > 1 ? -1 : h < 0 ? 1 : 0; float result = 0; if (h * 6 < 1) { result = t2 + (t1 - t2) * 6f * h; } else if (h * 2 < 1) { result = t1; } else if (h * 3 < 2) { result = t2 + (t1 - t2) * (2f / 3f - h) * 6f; } else { result = t2; } return result; } }