Page 1 of 1

Way to find a lighter and darker shade of a RGB color?

Posted: Wed Feb 15, 2012 12:48 pm
by keithglong
Hi All,

I have a problem... If a user selects a color and I put it into a variable (as RGB), how can I find a shade that is several shades lighter, and a shade that is several shades darker, also in RGB format?

For example, I put 0,255,64 into myVar. (This color a shade of green.) Programmatically, how can I find a shade that is several shades lighter in green and a shade that is several shades darker in green from this base color?

(By the way... Is there a way in LiveCode to determine the hue, saturation, and brightness of a color and change the values?)

Any help would be most appreciated...

Thanks!

- Boo

Re: Way to find a lighter and darker shade of a RGB color?

Posted: Wed Feb 15, 2012 4:15 pm
by bn
Hi Keith,

I made a little stack to do what you want. It uses RGB colors.
Darken Lighten RGB.livecode.zip
(1.61 KiB) Downloaded 544 times


In a stack on RevOnline "EasterEgg" I use a HSV-RGB and the RGB-HSV library which is originally from Monte Goulding. They are in the card scipt.

http://revonline2.runrev.com/stack/347/EasterEgg

or via user samples from within Livecode

Kind regards

Bernd

Re: Way to find a lighter and darker shade of a RGB color?

Posted: Wed Feb 15, 2012 9:53 pm
by keithglong
Thanks Bernd!

Re: Way to find a lighter and darker shade of a RGB color?

Posted: Sun Dec 02, 2012 6:39 am
by AtoZ
Bernd,

Your script for finding lighter and darker versions of a color are exactly what I needed for a non-commercial project I'm working on. I'm assuming since you've posted it in a public forum that you will not object to it's reuse (in an adapted version). I would like to give you credit for the script some place in the project -- probably on the Credits card (subject to the approval of the developer) and most certainly in the comments before your code, if you could kindly let me know how you would like the credit to read.

Thanks so much.

John

Re: Way to find a lighter and darker shade of a RGB color?

Posted: Sun Dec 02, 2012 6:20 pm
by bn
Hi John,
Your script for finding lighter and darker versions of a color are exactly what I needed for a non-commercial project I'm working on. I'm assuming since you've posted it in a public forum that you will not object to it's reuse (in an adapted version)
glad you liked it and that it did help you. It is not rocket science but handy to have if needed.
Please feel free to use it any way you want, no need to credit me. If you want to put a link to the stack in the script you may want to reference this thread.

Kind regards
Bernd