def rgb2hex(tup, max=1):
    """ convert an rgb tuple into a hex color string representation

    Args:
        tup: tuple: tuple of length 3 representing the color
        max=1: the maximum value for the values in the tuple.
            This will be used to scale the tuple values as integers between 0 and 255.
    
    Returns:
        color: str: hex color string representation (format "aaaaaa" - no "#")
    """
    tup = [int(c * 255 / max) for c in tup]
    color = ""
    for c in tup:
        if c < 16:
            c = "0" + hex(c)[-1:]
        else:
            c = hex(c)[-2:]
        color += c
    return color.upper()