Here you can find the source of HSLtoRGB(float h, float s, float l)
private static int HSLtoRGB(float h, float s, float l)
//package com.java2s; /******************************************************************************* * Copyright (c) 2001-2006 Mathew A. Nelson and Robocode contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.robocode.net/license/CPLv1.0.html * //from w w w. j a v a2 s . co m * Contributors: * Flemming N. Larsen * - Initial implementation *******************************************************************************/ public class Main { private static int HSLtoRGB(float h, float s, float l) { float m2 = (l <= 0.5f) ? (l * (s + 1)) : (l + s - l * s); float m1 = 2 * l - m2; int r = (int) (255 * HUEtoRGB(m1, m2, h + (1f / 3))); int g = (int) (255 * HUEtoRGB(m1, m2, h)); int b = (int) (255 * HUEtoRGB(m1, m2, h - (1f / 3))); return (((r << 8) | g) << 8) | b; } private static float HUEtoRGB(float m1, float m2, float h) { if (h < 0) { h++; } if (h > 1) { h--; } if ((h * 6) < 1) { return m1 + (m2 - m1) * h * 6; } if ((h * 2) < 1) { return m2; } if ((h * 3) < 2) { return m1 + (m2 - m1) * ((2f / 3) - h) * 6; } return m1; } }