Skip to content
Converts your hex or RGB values into Corona/Defold-compatible format
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
convertcolor.lua

README.md

Lua Color Converter

Converts your hex or RGB values into Corona/Defold-compatible format (numbers from 0 to 1)

HowTo:

  1. Put convertcolor.lua into your project directory

  2. Load it from your files (where it's necessary)

local color = require("convertcolor")
  1. Use it to convert from hex:
color.hex("ff00ff") --change ff00ff to your color

.. and to convert from regular rgb:

color.rgb(255, 0, 255) --change 255, 0, 255 to your red, green, blue channels respectively

You can use one more argument to set alpha channel:

color.hex("ff00ff", 0.5) --alpha set to 50%
color.rgb(255, 0, 255, 75) --alpha set to 75%

Examples:

local myText = display.newText( "example from Corona Docs", 0, 0, native.systemFontBold, 12 )
myText:setFillColor( color.hex("ff10ae") )
go.set("#label", "color", vmath.vector4(color.rgb(255, 16, 174, 1))
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.