Search code examples
androidandroid-canvasdrawglow

Trying to replicate glowing circle effect


I am trying to replicate the glowing effect of the circles in this game: http://hakim.se/experiments/html5/coil/

Currently I can draw a circle with:

canvas.drawCircle(Parameters);

However I have no idea how to make the circles emit that soft glowing effect.

So far it seems like I need to use a paint's shadow layer but that is not working.

Here is what I currently have:

blue = new Paint(); //This is in my view's constructor.
blue.setARGB(255, 51, 153, 255);
blue.setShadowLayer(100,0,0, Color.BLUE);

Then I have this in the onDraw method:

canvas.drawCircle(300,300,20,blue); 

However I do not see any glow effect.

How can I achieve/mimic the glowing effect of those circles either by using shadow layers or something else?


Solution

  • Just add this line of code where you've initialized the paint.

    setLayerType(LAYER_TYPE_SOFTWARE, blue);
    

    Screen-shot:

    glowing circle