• Advertisement

Archived

This topic is now archived and is closed to further replies.

whats the formula for inverting color/

This topic is 5558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
255-r,255-g,255-b,255-a

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
or
R = ~R;
G = ~G;
B = ~B;

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement