code: public static float[] toHSL(float red, float green, float blue) {
  
  		validateArithmeticRGB(red);
  		validateArithmeticRGB(green);
  		validateArithmeticRGB(blue);
  
  		float min = Math.min(Math.min(red, green), blue);
  		float max = Math.max(Math.max(red, green), blue);
  
  		float range = max - min;
  
  		float hue = 0.0f;
  		if (range > 0.0f) {
  			if (red >= green && red >= blue) {
  				hue = (green - blue) / range;
  			} else if (green >= blue) {
  				hue = 2 + (blue - red) / range;
  			} else {
  				hue = 4 + (red - green) / range;
  			}
  		}
  
  		hue *= 60.0f;
  		if (hue < 0.0f) {
  			hue += 360.0f;
  		}
  
  		float sum = min + max;
  
  		float lightness = sum / 2.0f;
  
  		float saturation;
  		if (min == max) {
  			saturation = 0.0f;
  		} else {
  			if (lightness < 0.5f) {
  				saturation = range / sum;
  			} else {
  				saturation = range / (2.0f - max - min);
  			}
  		}
  
  		return new float[] { hue, saturation, lightness };
  	}
docs: Convert red, green, and blue arithmetic values to HSL (hue, saturation,
  lightness) values
  
  @param red
  red color inclusively between 0.0 and 1.0
  @param green
  green color inclusively between 0.0 and 1.0
  @param blue
  blue color inclusively between 0.0 and 1.0
  @return HSL array where: 0 = hue, 1 = saturation, 2 = lightness