Gradient Text in Corona

By | January 24, 2012

To create gradient text in corona, you have to download ‘Corona daily build 612’ which has functions like setFillColor() etc.
You create a new gradient object by calling graphics.newGradient().
You can pass (and reuse) the object in calls to text:setTextColor() and rect:setFillColor().

Here is an example.

local myText =
    display.newText( "Hello, World!", 0, 0, native.systemFont, 40 )
myText.x = display.contentWidth * 0.5
myText.y = display.contentWidth * 0.25
local g = graphics.newGradient( { 180, 180, 0 }, { 255 }, "down" )
myText:setTextColor( g )

Leave a Reply

Your email address will not be published. Required fields are marked *