Latest Tweets

 

Creating a colourful glow in Android

In a previous post, I described how I could dynamically generate a continually evolving logo by masking and layering several different bitmaps.

This worked well enough, but failed to look convincing when the rendered texture was light. I overcame this by creating a halo effect, to make brightly textured emblems appear to luminesce. Again, the 2D rendering apis in Android made this very easy.

I start the process with the rendered texture in a Bitmap:

Texture

Using a Canvas over a tiny 3x3 Bitmap I produced a scaled copy of the texture.

Lowres

Using the Bitmap.getPixels() method, I created a SweepGradient through the eight outermost colours.

Sweep

Finally using a black-to-white-to-black RadialGradient applied with a PorterDuff.Mode of MULTIPLY a circular ring is of compatible colours is created:

Ring

This ring can then be overlayed separately onto the existing image, using the useful TransitionDrawable class to smoothly switch halos.

The final effect can be seen in this video

blog comments powered by Disqus