def calculate_error(source, target, base, alpha):
    """
    Calculates error for a given source/target/base colors and alpha
    """
    alpha /= 255.0
    alpha_inverse = 1.0 - alpha
    return abs(target - alpha * source - alpha_inverse * base)