because Hindley-Milner rocks
In my last post I was thrilled that something unexpected came out looking good. I could see using what I’d done as a fader or for dramatic effect in an application. In fact, my excitement was less about what had happened in comparison to what I could do with it.
So why did it occur? Those that have programmed in a UI environment or worked with OpenGL can answer that question quickly, Alpha Blending. It seems that the default blending scheme used by Android is not an “overwrite” setting but rather a “blend” setting. Here’s a visual presentation of what each of those schemes looks like when composing bitmaps in successive order interspersed with calls to Canvas.drawColor:
How about if we use a different color in the call to Canvas.drawColor? Is it the fact that I’ve used black which is having such a profound effect?
So there you have it. Background color does play an important role in how the alpha blending is applied with respect to this one function call. I’ll start playing around with clipped portions of the canvas and see what effects I can uncover there. In the meantime I hope you enjoyed this post.