(r, g, b, alpha=1.0)
return hue, sat, lightness, alpha
Converts a color given by its RGBA coordinates to HSLA coordinates
    (hue, saturation, lightness, alpha).

    Each of the RGBA coordinates must be in the range [0, 1].
Converts a color given by its RGBA coordinates to HSLA coordinates
    (hue, saturation, lightness, alpha).
Converts a color given by its RGBA coordinates to HSLA coordinates ( hue saturation lightness alpha ) .
def rgba_to_hsla(r, g, b, alpha=1.0):
    """Converts a color given by its RGBA coordinates to HSLA coordinates
    (hue, saturation, lightness, alpha).

    Each of the RGBA coordinates must be in the range [0, 1].
    """
    alpha = float(alpha)
    rgb_min, rgb_max = float(min(r, g, b)), float(max(r, g, b))

    if rgb_min == rgb_max:
        return 0.0, 0.0, rgb_min, alpha

    lightness = (rgb_min + rgb_max) / 2.0
    d = rgb_max - rgb_min
    if lightness > 0.5:
        sat = d / (2 - rgb_max - rgb_min)
    else:
        sat = d / (rgb_max + rgb_min)

    d *= 6.0
    if rgb_max == r:
        hue = (g - b) / d
        if g < b:
            hue += 1
    elif rgb_max == g:
        hue = 1 / 3.0 + (b - r) / d
    else:
        hue = 2 / 3.0 + (r - g) / d
    return hue, sat, lightness, alpha
def rgba_to_hsla ( r , g , b , alpha = 1.0 ) : alpha = float ( alpha ) rgb_min , rgb_max = float ( min ( r , g , b ) ) , float ( max ( r , g , b ) ) if rgb_min == rgb_max : return 0.0 , 0.0 , rgb_min , alpha lightness = ( rgb_min + rgb_max ) / 2.0 d = rgb_max - rgb_min if lightness > 0.5 : sat = d / ( 2 - rgb_max - rgb_min ) else : sat = d / ( rgb_max + rgb_min ) d *= 6.0 if rgb_max == r : hue = ( g - b ) / d if g < b : hue += 1 elif rgb_max == g : hue = 1 / 3.0 + ( b - r ) / d else : hue = 2 / 3.0 + ( r - g ) / d return hue , sat , lightness , alpha