Is radial gradient fill broken?

I have been trying to get a very simple, circular radial gradient fill using the Gfx2.0 generator effect. What I would like is a light green to dark green, circular gradient fill with a very narrow gradient between the two colours.

It appears, to me, as though the colour definitions are broken in the effect.colour1 and effect.colour2 parameters.

Let’s take the Gfx2.0 colour definitions for green and grey with full opacity:

  • Green: { 0, 1, 0, 1 }
  • Grey: { .5, .5, .5, 1 }

These are demonstrated with a couple of squares:

display.newRect( 100,100, 50,50 ).fill = {0,1,0,1} display.newRect( 150,100, 50,50 ).fill = {.5,.5,.5,1}

Which renders this:

The following code should render a square with a green to grey graduated radial fill.

local r = display.newRect( 200, 200, 100, 100 ) r.fill.effect = "generator.radialGradient" r.fill.effect.color1 = { 0.0, 0.8, 0, 1 } r.fill.effect.color2 = { 0.5, 0.5, 0.5, 1 } r.fill.effect.center\_and\_radiuses = { .5,.5 , .15,.35 } r.fill.effect.aspectRatio = r.width/r.height

But it doesn’t. What it renders is this:

For comparison, here is the complete code for the three squares and the result:

display.newRect( 100,100, 50,50 ).fill = {0,1,0,1} -- green display.newRect( 150,100, 50,50 ).fill = {.5,.5,.5,1} -- grey local r = display.newRect( 200,100, 50,50 ) r.fill.effect = "generator.radialGradient" r.fill.effect.color1 = { 0.0, 1, 0, 1 } -- green r.fill.effect.color2 = { 0.5, 0.5, 0.5, 1 } -- grey (purple???) r.fill.effect.center\_and\_radiuses = { .5,.5 , .15,.35 } r.fill.effect.aspectRatio = r.width/r.height

Can anyone tell me why I cannot render green to grey with a specific area for the gradient fill to apply to?

As further demonstration of this (and the intended use) II’ve just posted this to the code exchange, though it does of course need some tweaking…

Would really like a solid explanation of how the gradient fill colour values work.

As further demonstration of this (and the intended use) II’ve just posted this to the code exchange, though it does of course need some tweaking…

Would really like a solid explanation of how the gradient fill colour values work.