def rgb_to_hsl(r, g, b) ->tuple:
    """
    Converts RGB tuple into HSL tuple
    Calculations are taken from  http://www.easyrgb.com/en/math.php

    :param r: Red (between 0 to 1)
    :param g: Green (between 0 to 1)
    :param b: Blue (between 0 to 1)
    :return: (hue, saturation, lightness) All between 0 to 1
    """
    min_rgb = min(r, g, b)
    max_rgb = max(r, g, b)
    delta_rgb = max_rgb - min_rgb
    l = (max_rgb + min_rgb) / 2
    if delta_rgb == 0:
        h = 0
        s = 0
    else:
        if l < 0.5:
            s = delta_rgb / (max_rgb + min_rgb)
        else:
            s = delta_rgb / (2 - max_rgb - min_rgb)
        delta_r = ((max_rgb - r) / 6 + delta_rgb / 2) / delta_rgb
        delta_g = ((max_rgb - g) / 6 + delta_rgb / 2) / delta_rgb
        delta_b = ((max_rgb - b) / 6 + delta_rgb / 2) / delta_rgb
        if r == max_rgb:
            h = delta_b - delta_g
        elif g == max_rgb:
            h = 1 / 3 + delta_r - delta_b
        else:
            h = 2 / 3 + delta_g - delta_r
        if h < 0:
            h += 1
        if h > 1:
            h -= 1
    return round(h, 3), round(s, 3), round(l, 3)
