def get_contrasting_bw(color):
    """Return black or white, whichever constrasts more.

    That is, whichever contrasts more with the given color.

    Parameters
    ==========
    color (tuple or list with rgb(a) values)
        values are integers ranging from 0 to 255
        (0 <= integer <= 255) and representing values of
        the RGB(A) channels of a color (though the alpha
        color is ignored here if it exists).
    """
    ### only consider the first three values
    color = color[:3]

    ### make it so the values are within the unit interval
    ### (float such that  0.0 <= float <= 1.0)
    color = tuple(item / 255 for item in color)

    ### get the luma from the rgb color
    luma = rgb_to_yiq(*color)[0]

    ### if luma is greater than 50%, return black,
    ### otherwise return white
    return (0, 0, 0) if luma > 0.5 else (255, 255, 255)
Return black or white, whichever constrasts more.

    That is, whichever contrasts more with the given color.

    Parameters
    ==========
    color (tuple or list with rgb(a) values)
        values are integers ranging from 0 to 255
        (0 <= integer <= 255) and representing values of
        the RGB(A) channels of a color (though the alpha
        color is ignored here if it exists).
    
nodezator/ourstdlibs/color/creation.py