def rgba2rgb(rgba, max_val=1):
    """Convert color code from ``rgba`` to ``rgb``"""
    alpha = rgba[-1]
    rgb = rgba[:-1]
    type_ = int if max_val == 255 else float
    # compute the color as alpha against white
    return tuple([type_(alpha * e + (1 - alpha) * max_val) for e in rgb])