Color Converter

Hello. I think this question was already on the forum but I didn’t find solution for me. 
Is there any color converter to auto-change color from HEX format and/or  rgb format to Corona format(0-1) ?
Yesterday found this but it converts only from name. 

Thank you for help.

I looked at the code there and I would suggest changing the return statement to:

return redColor, greenColor, blueColor

then you can:

local convertcolor = require( "convertcolor" ) local red, green, blue = convertcolor.hex("ab072f")

The variables red, green and blue would hold the value between 0…1 for the three different color channels. You can apply this directly to things like :setFillColor:

myObject:setFillColor( convertcolor.hex( "ab072f" ) )

And for things like widgets where the colors are in a table:

local button = widget.newButton({     label = "Hello World",     labelColor = { default = { convertcolor.hex("a0b342") }, over = { convertcolor.hex("ffeedd") } } })

Hmm… I have uploaded this code 2 days ago. It converts hex and rgb. Use only 2 functions. It should help you

This is the code the OP is referring to. You return a string with the values in it instead of the actual values.  If you change the return lines to:

return redColor, greenColor, blueColor

it would be much more useful.

Rob

This is what I use:

http://sputnik.freewisdom.org/lib/colors/

It does a lot of things.

Dave

Oh, I’m so stupid :frowning:
Sorry, I’ve just corrected it. Thank you.

I looked at the code there and I would suggest changing the return statement to:

return redColor, greenColor, blueColor

then you can:

local convertcolor = require( "convertcolor" ) local red, green, blue = convertcolor.hex("ab072f")

The variables red, green and blue would hold the value between 0…1 for the three different color channels. You can apply this directly to things like :setFillColor:

myObject:setFillColor( convertcolor.hex( "ab072f" ) )

And for things like widgets where the colors are in a table:

local button = widget.newButton({     label = "Hello World",     labelColor = { default = { convertcolor.hex("a0b342") }, over = { convertcolor.hex("ffeedd") } } })

Hmm… I have uploaded this code 2 days ago. It converts hex and rgb. Use only 2 functions. It should help you

This is the code the OP is referring to. You return a string with the values in it instead of the actual values.  If you change the return lines to:

return redColor, greenColor, blueColor

it would be much more useful.

Rob

This is what I use:

http://sputnik.freewisdom.org/lib/colors/

It does a lot of things.

Dave

Oh, I’m so stupid :frowning:
Sorry, I’ve just corrected it. Thank you.