

def _blend_colors(color_1, color_2):
    "Blend two colors in HSV space\n\n    Parameters\n    ----------\n    color_1, color_2 : None | tuple\n        RGBA tuples with values between 0 and 1. None if no color is available.\n        If both colors are None, the output is None. If only one is None, the\n        output is the other color.\n\n    Returns\n    -------\n    color : None | tuple\n        RGBA tuple of the combined color. Saturation, value and alpha are\n        averaged, whereas the new hue is determined as angle half way between\n        the two input colors' hues.\n    "
    if ((color_1 is None) and (color_2 is None)):
        return None
    elif (color_1 is None):
        return color_2
    elif (color_2 is None):
        return color_1
    (r_1, g_1, b_1, a_1) = color_1
    (h_1, s_1, v_1) = rgb_to_hsv(r_1, g_1, b_1)
    (r_2, g_2, b_2, a_2) = color_2
    (h_2, s_2, v_2) = rgb_to_hsv(r_2, g_2, b_2)
    hue_diff = abs((h_1 - h_2))
    if (hue_diff < 0.5):
        h = (min(h_1, h_2) + (hue_diff / 2.0))
    else:
        h = (max(h_1, h_2) + ((1.0 - hue_diff) / 2.0))
        h %= 1.0
    s = ((s_1 + s_2) / 2.0)
    v = ((v_1 + v_2) / 2.0)
    (r, g, b) = hsv_to_rgb(h, s, v)
    a = ((a_1 + a_2) / 2.0)
    color = (r, g, b, a)
    return color

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py _blend_colors/original