def apply_rect_mask_to_layer(source, alpha):
    """ Same as apply_mask_to_layer(), but for single pixels. Also always uses black background,
        since it's for greyscale masks.
    """
    dest = 0
    if alpha == 0:
        return dest
    if alpha == 255:
        return source
    alpha_pct = alpha / 255.0
    new_rgb = int(source * alpha_pct + dest * (1 - alpha_pct))
    return new_rgb
