Sam Hogan
Sam Hogan

Reputation: 179

Corona sdk linear color ramp?

Ok, I have a very, very large background image, well not an image but a rectangle colored blue:

bg2 =display.newRect(0,0,20000,20000)
bg2.y=10000
bg2:setFillColor( 0 , 0, 225)

Is it possible to make the rectangle not just one solid color, but a linear color ramp from black to blue? In other words, the color fades from black to blue vertically. I don't want to use an image, because it would be way too large.

Upvotes: 3

Views: 273

Answers (1)

Ryan Stein
Ryan Stein

Reputation: 8000

You're looking for a gradient fill color, such as this.

local black = {0, 0, 0}
local blue = {0, 0, 1}
local g = {type="gradient", color1=black, color2=blue}

bg2:setFillColor(g)

Upvotes: 2

Related Questions