def color2hex(color):
    """Return a hexadecimal string with '#' prepended for the Color instance."""
    r, g, b, a = color
    x = '#{:06x}'.format(r * 65536 + g * 256 + b)
    if a < 1:
        x += format(int(a * 255), '02x')
    return x
