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 / Simple Inverse Color functions

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 1st Sep 2006 23:09 Edited at: 1st Sep 2006 23:10
This one's for the newbies to use. I'm pretty sure most people can work it out ourselves, but I'm gonna post this anyway.




[edit]
Ment to say 'function' (without the s) in the title.

Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 3rd Sep 2006 03:19
why not just XOR the raw color value, gives same effect I think and much faster

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Sep 2006 14:25
What's XOR?

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 3rd Sep 2006 22:26
Here's the xor way and another way that you just do -color-1 to get the inverse of color, which I think is nearly the same as xor, from a binary point of view.
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 3rd Sep 2006 22:42
what it does at the binary level though is inverts every bit
such as 0110 becomes 1001

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Sep 2006 00:30
Ahh I see, cool.

CodemanV
19
Years of Service
User Offline
Joined: 25th Aug 2005
Location: South Wales Valleys, UK
Posted: 4th Sep 2006 03:02 Edited at: 4th Sep 2006 03:40
Hello

You could also apply 2's-Compliment to the colour using bitwise NOT (..) and adding 1.

2's compliment steps
Flip all the bits
Add 1

*** edit ***
Also, colour variables should be assigned as a dword. tsk, tsk!



*** edit 2 ***
it just occured to me that by inverting the colour, the alpha byte was also inverted.

This function sorts that out.

Login to post a reply

Server time is: 2024-11-23 03:50:36
Your offset time is: 2024-11-23 03:50:36