Radial fill with alpha component

Really thinking either this is so easy I’m getting it wrong or it’s just not that easy…

I want to fill an object with a radial, rather than linear, gradient which fills from a solid (alpha = 1) to transparent (alpha = 0) pair of colours.

The code I’m looking at right now is:

local c = display.newCircle( 300, 300, 150 ) c.fill.effect = "generator.radialGradient" c.fill.effect.color1 = { .5,.5,1, 1 } c.fill.effect.color2 = { .5,.5,1, 0 } c.fill.effect.center\_and\_radiuses = { 0.5, 0.5, 0, 1 }

As you can see, color2 - as a normal fill - would make the object invisible due to an alpha of 0. Here, however, this is not happening; It appears to fill toward whichever colour is the default for the non-gradient fill (in this case, white {1,1,1}).

My solution is currently this:

function display.newRadialFillCircle( parent, x, y, r, c ) local group = display.newGroup() group.x, group.y = x, y parent = parent or display.currentStage parent:insert( group ) local ringinc = 100/(r/4) local a = 0 for i=r, 2, -4 do local circle = display.newCircle( group, 0, 0, i-2 ) circle.fill = {0,0,0,0} circle.strokeWidth = 4 a = a + ringinc c[4] = a/100 circle.stroke = c end end display.newRadialFillCircle( nil, 400, 400, 350, { .7, .7, 1 } )

My solution is currently this:

function display.newRadialFillCircle( parent, x, y, r, c ) local group = display.newGroup() group.x, group.y = x, y parent = parent or display.currentStage parent:insert( group ) local ringinc = 100/(r/4) local a = 0 for i=r, 2, -4 do local circle = display.newCircle( group, 0, 0, i-2 ) circle.fill = {0,0,0,0} circle.strokeWidth = 4 a = a + ringinc c[4] = a/100 circle.stroke = c end end display.newRadialFillCircle( nil, 400, 400, 350, { .7, .7, 1 } )