Convert HEX to RGB values to new Corona SDK standards

With the release of the 2.0 Graphics the Corona SDK made a little change to the way color values must be passed throughout its related functions.
Basically, instead of RGB values within a range of 0-255, all values must now be between 0-1.

It’s kind of a trivial change, but it has added a new necessary step that might be quite a bother at times.

The solution is pretty simple:

We just need to divide our previous 0-255 values by 255. You can either use our library to automatically do so, or divide your values by yourself.

At times, you might prefer to use hex values. Here’s how to use any colors Hex values instead:

Here’s our function, and here’s how to use it:

You can download this library here

 

 

1 Comment

  1. I’ll be using the hex converter in all my apps. Thanks!