whats the formula for inverting color/

Started by
6 comments, last by IFooBar 21 years, 4 months ago
Hi say I have an RGBA value of 100,120,200,230. How would i get the inverse? it cant possibly be 1/200, 1/120,1/200, 1/230! thanks for help :::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile
[size=2]aliak.net
Advertisement
255-r,255-g,255-b,255-a
Every RGBA component has a value of 0 to 255. So an inverted color is 255-the value.
R,G,B,A -> 255-R, 255-G, 255-B, 255-A
[My Lousy Page | Kings Of Chaos | Vampires | [email=lordlethis@hotmail.com]email.me[/email]]
thanks a bunch

:::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile
[size=2]aliak.net
You can also do this:
R= R*-1 + 255
G= G*-1 + 255
B= B*-1 + 255
or
R = ~R;
G = ~G;
B = ~B;
What does that mean???
Andos:

~ for integers is a "bitwise NOT".

i.e. every binary 1 bit becomes a 0 and vice versa.



We could go on for days posting subtle and obfuscated code snippets which all do the same basic thing of inverting the colour. I think the basic question has been answered though


r = r^255;
g = g^255;
b = b^255;



--
Simon O'Connor
Creative Asylum Ltd
www.creative-asylum.com

[edited by - S1CA on December 8, 2002 11:15:21 AM]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement