public static RgbaColor fromHsl ( float H , float S , float L ) { // convert to [0-1] H /= 360f ; S /= 100f ; L /= 100f ; float R , G , B ; if ( S == 0 ) { // grey R = G = B = L ; } else { float m2 = L <= 0.5 ? L * ( S + 1f ) : L + S - L * S ; float m1 = 2f * L - m2 ; R = hue2rgb ( m1 , m2 , H + 1 / 3f ) ; G = hue2rgb ( m1 , m2 , H ) ; B = hue2rgb ( m1 , m2 , H - 1 / 3f ) ; } // convert [0-1] to [0-255] int r = Math . round ( R * 255f ) ; int g = Math . round ( G * 255f ) ; int b = Math . round ( B * 255f ) ; return new RgbaColor ( r , g , b , 1 ) ; }
Creates a new RgbaColor from the specified HSL components .