- public static int[] hslToRgb(Double h, Double s, Double l){
- Double r, g, b;
-
- if(s == 0){
- r = g = b = l; // achromatic
- } else {
- Double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- Double p = 2 * l - q;
- r = hue2rgb(p, q, h + 1/3) * 255;
- g = hue2rgb(p, q, h) * 255;
- b = hue2rgb(p, q, h - 1/3) * 255;
+ public static int[] HSLtoRGB(float h, float s, float l, float alpha)
+ {
+ if (s <0.0f || s > 100.0f)
+ {
+ String message = "Color parameter outside of expected range - Saturation";
+ throw new IllegalArgumentException( message );
+ }
+
+ if (l <0.0f || l > 100.0f)
+ {
+ String message = "Color parameter outside of expected range - Luminance";
+ throw new IllegalArgumentException( message );
+ }
+
+ if (alpha <0.0f || alpha > 1.0f)
+ {
+ String message = "Color parameter outside of expected range - Alpha";
+ throw new IllegalArgumentException( message );