I made this plugin awhile ago, and it’s now free on the Solar2D directory. Hope you guys enjoy it.
Here’s some examples
-- setup
local materialColors = require "plugin.materialcolors"
materialColors.initHooks()
-- Hex
local circle = display.newCircle( 100, 100, 50 )
circle:setFillColor( "#FF0000" )
circle.stroke = 5
circle:setStrokeColor( "#00FF00" )
-- Hex with alpha
local circle = display.newCircle( 100, 100, 50 )
circle:setFillColor( "#FF00007F" ) -- about 50% alpha because of the 7F appended at the end
circle.stroke = 5
circle:setStrokeColor( "#00FF0000" ) -- 0% alpha because of the 00 appended at the end
-- Material Color
local circle = display.newCircle( 100, 100, 50 )
circle:setFillColor( "red350" )
circle.stroke = 5
circle:setStrokeColor( "green500" )
-- Material Color with alpha
local circle = display.newCircle( 100, 100, 50 )
circle:setFillColor( "red350-50" ) -- 50% alpha because of the -50 appended at the end
circle.stroke = 5
circle:setStrokeColor( "green500-0" ) -- 0% alpha because of the -0 appended at the end
Include it in your project now like this
{
plugins = {
["plugin.materialcolors"] = {
publisherId = "io.joehinkle",
},
},
}
GitHub repo: https://github.com/solar2d/io.joehinkle-plugin.materialcolors/
Enjoy!