Evaluating RGB?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
teacherguy
Posts: 379
Joined: Thu Dec 08, 2011 2:43 am

Evaluating RGB?

Post by teacherguy » Wed Nov 23, 2016 12:40 pm

I would like to change the drop shadow behind text from black to white depending on the textcolor that the user selects. Does anyone have a way of evaluating the RGB in order to determine a darker color (say blue) from a lighter one (say yellow)?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10350
Joined: Wed May 06, 2009 2:28 pm

Re: Evaluating RGB?

Post by dunbarx » Wed Nov 23, 2016 3:09 pm

Hi.

Well, "0,0,0" is pretty light, and if you start increasing the values of any of the three RGB values, the color will get "darker".

But is full yellow darker than full red? No, I guess. I think it better if you limit the color options to a fixed set, and create a look-up table so that you can map one to the other as you desire.

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Evaluating RGB?

Post by jacque » Wed Nov 23, 2016 5:39 pm

I think you're looking for luminance values:

http://runtime-revolution.278305.n4.nab ... l#a4709206
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

teacherguy
Posts: 379
Joined: Thu Dec 08, 2011 2:43 am

Re: Evaluating RGB?

Post by teacherguy » Wed Nov 23, 2016 7:14 pm

Superb, thanks Jacque

Post Reply