Color Picker Library - add a color picker to your app with just one line of code!

Hi Everybody,

Just wanted to let you all know that I’m sharing what I think is a pretty great color picker library/module. It is Graphics 2.0-compatible, and brings up an Adobe-style color picker box along with an alpha channel slider with just one line of code. I borrowed heavily from StarCrunch’s Code Exchange post from last year (http://developer.coronalabs.com/code/color-picker), but I think I made enough improvements to say my picker can stand alone as a separate product.

I wrote a blog post about it on my own site, with details on usage and a sample project you can download: http://www.jasonschroeder.com/2014/03/24/add-a-color-picker-to-your-corona-app-with-one-line-of-code/.

You can also find the colorPicker.lua library file on the Corona Labs Code Exchange: http://code.coronalabs.com/code/color-picker-color-picker-your-app-just-one-line-code

Here is a video of how it looks in action:

https://www.youtube.com/watch?v=r9nZzovrPbk

Hope some of you find it useful!

Cool!

+1 Jason - well done and great work showing examples of usage on your website.

Ah, very cool.

Alpha cropped up in my mind occasionally while doing the original, but I was never sure how much I’d need it. I’ve still been too lazy to make the horizontal bar option. :slight_smile:

I didn’t dig too far to see what you preserved, but if you’re having issues with drags snagging on edges / corners, I’ve since fixed that up: https://github.com/ggcrunchy/corona-sdk-snippets/blob/master/ui/ColorPicker.lua#L88 and thereabouts. (A bunch of the color code has been pulled into another module, but I think the relevant stuff is still there.)

Thanks tschussler, and thanks for commenting, StarCrunch! I already made it so that the picker will keep tracking your finger, even if you slide it off the edge of the box/bar, but thanks! And really, I wouldn’t have put this thing together nearly so quickly without having your code to work off of, so thanks a ton for sharing!

Cool!

+1 Jason - well done and great work showing examples of usage on your website.

Ah, very cool.

Alpha cropped up in my mind occasionally while doing the original, but I was never sure how much I’d need it. I’ve still been too lazy to make the horizontal bar option. :slight_smile:

I didn’t dig too far to see what you preserved, but if you’re having issues with drags snagging on edges / corners, I’ve since fixed that up: https://github.com/ggcrunchy/corona-sdk-snippets/blob/master/ui/ColorPicker.lua#L88 and thereabouts. (A bunch of the color code has been pulled into another module, but I think the relevant stuff is still there.)

Thanks tschussler, and thanks for commenting, StarCrunch! I already made it so that the picker will keep tracking your finger, even if you slide it off the edge of the box/bar, but thanks! And really, I wouldn’t have put this thing together nearly so quickly without having your code to work off of, so thanks a ton for sharing!

Awesome work and thanks a lot for sharing!! Extremely useful library!

Awesome work and thanks a lot for sharing!! Extremely useful library!

Hi Jason,

Awesome color picker utility!!!

I was able to test out the color picker in the simulator but unfortunately you need to have a Pro or higher subscription to Corona SDk.

Unfortunately I only have the Starter edition - is there a workaround at all?

Thanks

Hi Anil,

Thanks for the compliment - glad you like the color picker! Unfortunately, as the module stands, there really isn’t any way to achieve it without some of the “pay wall” APIs - specifically, the “gradient paint” API, which is how the main color box and side color bar are created. You might be able to achieve it with pre-rendered images and (in the case of the color box) applying tints using object:setFillColor(), but I don’t have the time to put into it, I’m afraid. If you do manage to achieve a workaround, please share it - I’m sure there are other starter edition users who would love to use it!

Thanks,

Jason

Hi Jason,

Awesome color picker utility!!!

I was able to test out the color picker in the simulator but unfortunately you need to have a Pro or higher subscription to Corona SDk.

Unfortunately I only have the Starter edition - is there a workaround at all?

Thanks

Hi Anil,

Thanks for the compliment - glad you like the color picker! Unfortunately, as the module stands, there really isn’t any way to achieve it without some of the “pay wall” APIs - specifically, the “gradient paint” API, which is how the main color box and side color bar are created. You might be able to achieve it with pre-rendered images and (in the case of the color box) applying tints using object:setFillColor(), but I don’t have the time to put into it, I’m afraid. If you do manage to achieve a workaround, please share it - I’m sure there are other starter edition users who would love to use it!

Thanks,

Jason