def rgb_to_hex(r, g=0, b=0, a=0, alpha=False):
    """
    Returns the hexadecimal string of a color
    :param r: red channel
    :param g: green channel
    :param b: blue channel
    :param a: alpha channel
    :param alpha: if True, alpha will be used
    :return: color in a string format such as #abcdef
    """
    if type(r) is not list:
        color = [r, g, b, a]
    else:
        color = r
    hex = "#"
    for channel in color[:(4 if alpha else 3)]:
        temp = channel if type(channel) is int else int(round(channel * 255))
        hex += f'{temp:02x}'
    return hex