def rgb_to_hsl(r, g=None, b=None):
if type(r) in [list,tuple]:<EOL><INDENT>r, g, b = r<EOL><DEDENT>minVal = min(r, g, b)       <EOL>maxVal = max(r, g, b)       <EOL>l = (maxVal + minVal) / <NUM_LIT><EOL>if minVal==maxVal:<EOL><INDENT>return (<NUM_LIT:0.0>, <NUM_LIT:0.0>, l)    <EOL><DEDENT>d = maxVal - minVal         <EOL>if l < <NUM_LIT:0.5>: s = d / (maxVal + minVal)<EOL>else: s = d / (<NUM_LIT> - maxVal - minVal)<EOL>dr, dg, db = [(maxVal-val) / d for val in (r, g, b)]<EOL>if r==maxVal:<EOL><INDENT>h = db - dg<EOL><DEDENT>elif g==maxVal:<EOL><INDENT>h = <NUM_LIT> + dr - db<EOL><DEDENT>else:<EOL><INDENT>h = <NUM_LIT> + dg - dr<EOL><DEDENT>h = (h*<NUM_LIT>) % <NUM_LIT><EOL>return (h, s, l)<EOL>
Convert the color from RGB coordinates to HSL.

    Parameters:
      :r:
        The Red component value [0...1]
      :g:
        The Green component value [0...1]
      :b:
        The Blue component value [0...1]

    Returns:
      The color as an (h, s, l) tuple in the range:
      h[0...360],
      s[0...1],
      l[0...1]

    >>> rgb_to_hsl(1, 0.5, 0)
    (30.0, 1.0, 0.5)