def rgb_to_hsl(r, g, b):
    """Convert a color in r, g, b to a color in h, s, l"""
    r = r or 0
    g = g or 0
    b = b or 0
    r /= 255
    g /= 255
    b /= 255
    max_ = max((r, g, b))
    min_ = min((r, g, b))
    d = max_ - min_

    if not d:
        h = 0
    elif r is max_:
        h = 60 * (g - b) / d
    elif g is max_:
        h = 60 * (b - r) / d + 120
    else:
        h = 60 * (r - g) / d + 240

    l = .5 * (max_ + min_)
    if not d:
        s = 0
    elif l < 0.5:
        s = .5 * d / l
    else:
        s = .5 * d / (1 - l)
    return tuple(map(normalize_float, (h % 360, s * 100, l * 100)))
def rgb_to_hsl ( r , g , b ) : r = r or 0 g = g or 0 b = b or 0 r /= 255 g /= 255 b /= 255 max_ = max ( ( r , g , b ) ) min_ = min ( ( r , g , b ) ) d = max_ - min_ if not d : h = 0 elif r is max_ : h = 60 * ( g - b ) / d elif g is max_ : h = 60 * ( b - r ) / d + 120 else : h = 60 * ( r - g ) / d + 240 l = .5 * ( max_ + min_ ) if not d : s = 0 elif l < 0.5 : s = .5 * d / l else : s = .5 * d / ( 1 - l ) return tuple ( map ( normalize_float , ( h % 360 , s * 100 , l * 100 ) ) )
Convert a color in r, g, b to a color in h, s, l