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
whats the formula for inverting color/
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
R,G,B,A -> 255-R, 255-G, 255-B, 255-A
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]
~ 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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement