#NEWLINE# def hsl_to_rgb( hue , saturation , lightness ) : #NEWLINE# #INDENT# '\n    :param hue: degrees\n    :param saturation: percentage\n    :param lightness: percentage\n    :returns: (r, g, b) as floats in the 0..1 range\n    ' #NEWLINE# hue = ( ( hue / 360 ) % 1 ) #NEWLINE# saturation = min ( 1 , max ( 0 , ( saturation / 100 ) ) ) #NEWLINE# lightness = min ( 1 , max ( 0 , ( lightness / 100 ) ) ) #NEWLINE# def hue_to_rgb( m1 , m2 , h ) : #NEWLINE# #INDENT# if ( h < 0 ) : #NEWLINE# #INDENT# h += 1 #NEWLINE# #UNINDENT# if ( h > 1 ) : #NEWLINE# #INDENT# h -= 1 #NEWLINE# #UNINDENT# if ( ( h * 6 ) < 1 ) : #NEWLINE# #INDENT# return ( m1 + ( ( ( m2 - m1 ) * h ) * 6 ) ) #NEWLINE# #UNINDENT# if ( ( h * 2 ) < 1 ) : #NEWLINE# #INDENT# return m2 #NEWLINE# #UNINDENT# if ( ( h * 3 ) < 2 ) : #NEWLINE# #INDENT# return ( m1 + ( ( ( m2 - m1 ) * ( ( 2 / 3 ) - h ) ) * 6 ) ) #NEWLINE# #UNINDENT# return m1 #NEWLINE# #UNINDENT# if ( lightness <= 0.5 ) : #NEWLINE# #INDENT# m2 = ( lightness * ( saturation + 1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# m2 = ( ( lightness + saturation ) - ( lightness * saturation ) ) #NEWLINE# #UNINDENT# m1 = ( ( lightness * 2 ) - m2 ) #NEWLINE# return ( hue_to_rgb ( m1 , m2 , ( hue + ( 1 / 3 ) ) ) , hue_to_rgb ( m1 , m2 , hue ) , hue_to_rgb ( m1 , m2 , ( hue - ( 1 / 3 ) ) ) )