#NEWLINE# def hsl2rgb( hsl ) : #NEWLINE# #INDENT# 'Convert HSL representation towards RGB\n\n    :param h: Hue, position around the chromatic circle (h=1 equiv h=0)\n    :param s: Saturation, color saturation (0=full gray, 1=full color)\n    :param l: Ligthness, Overhaul lightness (0=full black, 1=full white)\n    :rtype: 3-uple for RGB values in float between 0 and 1\n\n    Hue, Saturation, Range from Lightness is a float between 0 and 1\n\n    Note that Hue can be set to any value but as it is a rotation\n    around the chromatic circle, any value above 1 or below 0 can\n    be expressed by a value between 0 and 1 (Note that h=0 is equiv\n    to h=1).\n\n    This algorithm came from:\n    http://www.easyrgb.com/index.php?X=MATH&H=19#text19\n\n    Here are some quick notion of HSL to RGB convertion:\n\n    >>> from colour import hsl2rgb\n\n    With a lightness put at 0, RGB is always rgbblack\n\n    >>> hsl2rgb((0.0, 0.0, 0.0))\n    (0.0, 0.0, 0.0)\n    >>> hsl2rgb((0.5, 0.0, 0.0))\n    (0.0, 0.0, 0.0)\n    >>> hsl2rgb((0.5, 0.5, 0.0))\n    (0.0, 0.0, 0.0)\n\n    Same for lightness put at 1, RGB is always rgbwhite\n\n    >>> hsl2rgb((0.0, 0.0, 1.0))\n    (1.0, 1.0, 1.0)\n    >>> hsl2rgb((0.5, 0.0, 1.0))\n    (1.0, 1.0, 1.0)\n    >>> hsl2rgb((0.5, 0.5, 1.0))\n    (1.0, 1.0, 1.0)\n\n    With saturation put at 0, the RGB should be equal to Lightness:\n\n    >>> hsl2rgb((0.0, 0.0, 0.25))\n    (0.25, 0.25, 0.25)\n    >>> hsl2rgb((0.5, 0.0, 0.5))\n    (0.5, 0.5, 0.5)\n    >>> hsl2rgb((0.5, 0.0, 0.75))\n    (0.75, 0.75, 0.75)\n\n    With saturation put at 1, and lightness put to 0.5, we can find\n    normal full red, green, blue colors:\n\n    >>> hsl2rgb((0 , 1.0, 0.5))\n    (1.0, 0.0, 0.0)\n    >>> hsl2rgb((1 , 1.0, 0.5))\n    (1.0, 0.0, 0.0)\n    >>> hsl2rgb((1.0/3 , 1.0, 0.5))\n    (0.0, 1.0, 0.0)\n    >>> hsl2rgb((2.0/3 , 1.0, 0.5))\n    (0.0, 0.0, 1.0)\n\n    Of course:\n    >>> hsl2rgb((0.0, 2.0, 0.5))  # doctest: +ELLIPSIS\n    Traceback (most recent call last):\n    ...\n    ValueError: Saturation must be between 0 and 1.\n\n    And:\n    >>> hsl2rgb((0.0, 0.0, 1.5))  # doctest: +ELLIPSIS\n    Traceback (most recent call last):\n    ...\n    ValueError: Lightness must be between 0 and 1.\n\n    ' #NEWLINE# ( h , s , l ) = [ float ( v ) for v in hsl ] #NEWLINE# if ( not ( ( 0.0 - FLOAT_ERROR ) <= s <= ( 1.0 + FLOAT_ERROR ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Saturation must be between 0 and 1.' ) #NEWLINE# #UNINDENT# if ( not ( ( 0.0 - FLOAT_ERROR ) <= l <= ( 1.0 + FLOAT_ERROR ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Lightness must be between 0 and 1.' ) #NEWLINE# #UNINDENT# if ( s == 0 ) : #NEWLINE# #INDENT# return ( l , l , l ) #NEWLINE# #UNINDENT# if ( l < 0.5 ) : #NEWLINE# #INDENT# v2 = ( l * ( 1.0 + s ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# v2 = ( ( l + s ) - ( s * l ) ) #NEWLINE# #UNINDENT# v1 = ( ( 2.0 * l ) - v2 ) #NEWLINE# r = _hue2rgb ( v1 , v2 , ( h + ( 1.0 / 3 ) ) ) #NEWLINE# g = _hue2rgb ( v1 , v2 , h ) #NEWLINE# b = _hue2rgb ( v1 , v2 , ( h - ( 1.0 / 3 ) ) ) #NEWLINE# return ( r , g , b )