A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Color Picker Library - add a color picker to your app with just one line of code!
Started by schroederapps Mar 24 2014 04:48 PM

7 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 225 posts
  • Enterprise

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:

 

Hope some of you find it useful!



[TOPIC: post.html]
#2

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,635 posts
  • Enterprise

[TOPIC: post.html]
#3

tschussler

[GLOBAL: userInfoPane.html]
tschussler
  • Enthusiast

  • 76 posts
  • Enterprise

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



[TOPIC: post.html]
#4

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 138 posts
  • Corona SDK

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. :)

 

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.)



[TOPIC: post.html]
#5

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 225 posts
  • Enterprise

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!



[TOPIC: post.html]
#6

Skatan

[GLOBAL: userInfoPane.html]
Skatan
  • Contributor

  • 542 posts
  • Enterprise

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



[TOPIC: post.html]
#7

anil8

[GLOBAL: userInfoPane.html]
anil8
  • Observer

  • 19 posts
  • Corona SDK

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



[TOPIC: post.html]
#8

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 225 posts
  • Enterprise

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




[topic_controls]
[/topic_controls]