Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Color Functions

Author
Message
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 30th Jun 2007 15:45 Edited at: 30th Jun 2007 17:42
Hi. I have made some color functions and I figured I'd post them here. You may or may not find then useful, but here they are. They're all very simple.

BrightenColor( color , brightness amount )

Will return the brightened version of a color. The COLOR parameter specifies the color, and the BRIGHTNESS AMOUNT specifies how much brightness you want to apply. Specifying a negative brightness amount will darken the color.

Function:


Example:




ColorOpposite( color )

Will return the opposite of a color.

Function:


Example:




Greyscale( color )

Returns the greyscale version of a color.

Function:


Example:


-------------------------------------------------------------------
Here's a full example showing all of them in action:



Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th Jun 2007 17:36

is also the same as


abs() is a pretty slow command. What you do is inputting one color at a time. But when you expand to lighten, darken, negative and greyscale a whole image (width*height times that algorithm), those small differences in ms are pretty important then.

Else than that, pretty convenient.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 30th Jun 2007 17:43
I knew I had done something wrong when I wrote that function... Thanks for pointing that out. It's changed now

Login to post a reply

Server time is: 2024-11-22 19:04:32
Your offset time is: 2024-11-22 19:04:32