A collective moan went around when we found that the way we have been handling colors in our Corona apps, using the standard RGB decimal format we have gotten used to, has been changed in the new build. Going forward, we need to set our colors using RGB percent. The reasons why this change was made is explained here: http://forums.coronalabs.com/topic/40216-why-change-the-color-parameter-values/?hl=%2Bgraphics+%2B2.0+%2Bcolors
TL;DR – I explain it all here: http://www.coronalabs.com/blog/coronageek/converting-color-codes-corona-sdk/
Several solutions have been proposed to use this new build and its color handling. You can:
- create a function to convert your colors
- divide each element by 255 like this: local back:setStrokeColor(25/255, 25/255, 25/255)
- throw up your hands and run your app in compatibility mode
The first two introduce overhead in terms of processing, which we really don’t need if we want to optimize our app’s speed. Using compatibility mode isn’t a great idea either as eventually it’s sure to be deprecated.
So I have a solution that is pretty fast and usable going forward. First I grab my color palette from Kuler, making note of the HEX color in the palette: https://kuler.adobe.com/create/color-wheel/
Then, go to this great website, http://www.colorhexa.com. Append your color’s HEX code into the url like this: http://www.colorhexa.com/2980b9 (that’s the blue I use for my background’s stroke in SevenMinutes).
Take a look at the different ways colors are listed. All these choices!
The hexadecimal color #2980b9 has RGB values of R:41, G:128, B:185 and CMYK values of C:0.78, M:0.31, Y:0, K:0.27. Its decimal value is 2719929.
- Hex triplet 2980b9
- RGB Decimal 41, 128, 185
- RGB Percent 16.1, 50.2, 72.5
What we care about is the RGB Percent.
Grab those numbers and plonk them into your RGB color value settings, after moving the decimal point two places to the left.
So what used to be
back:setStrokeColor(41, 128, 185)
back:setStrokeColor(.161, .502, .725)
So you now have your app looking decent again. Mischief managed!
Like my tutorials? You’ll love my apps. Please download, rate and review!