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

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Wed Feb 15, 2012 12:48 pm

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

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

Post by bn » Wed Feb 15, 2012 4:15 pm

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 541 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

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Wed Feb 15, 2012 9:53 pm

Thanks Bernd!

AtoZ
Posts: 64
Joined: Tue Mar 06, 2012 8:31 am
Location: San Diego, CA

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

Post by AtoZ » Sun Dec 02, 2012 6:39 am

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
Using LiveCode 5.5 on Windows 7 Home Premium Edition, Service Pack 1

Image
On my way from A TO Z, I often end up AT OZ.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

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

Post by bn » Sun Dec 02, 2012 6:20 pm

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

Post Reply

Return to “Multimedia”