Patent attributes
Methods and apparatus, including computer program products, for blending in the presence of different transparencies. In one aspect, the invention provides a computer implemented method for blending a first graphic element and a second graphic element in accordance with a transfer mode T, the first graphic element having a color A and an alpha a, the second graphic element having a color B and an alpha b. The method includes: calculating a resulting alpha as lerp(a, b, q), lerp being a linear interpolation function and q being a pseudo-opacity that varies between 1 and 0, inclusive; calculating a blended color as T(A, B, q); calculating an intermediate color as interpolate_color(A, blended color, min(b/resulting alpha, 1)), interpolate_color being a continuous function that interpolates its input colors and min being a function that selects the smaller of its input values; and calculating a result color as interpolate_color(B, intermediate color, min(a/resulting alpha, 1)).