Algorithm for calculating inverse color
newR = 1.0 - r
newG = 1.0 - g
newB = 1.0 - b
If the color has a premultiplied Alpha value use the alpha instead of 1.0:
newR = a - r
newG = a - g
newB = a - b
If you are using RGB values to 255, you could do something like this:
newR = 255 - r;
newG = 255 - g;
newB = 255 - b;
To understand this concept, imagine each value as a number line going from 0 to 255. If you graph a number on that number line then the number is that distance away from the beginning of the number line. In order to negate it, the number must travel to the other end of the number line. This algorithm basically flips the number line without moving the beginning or the end. Our number line is from 0 to 255, so, if the number was 10 away from the beginning (10), now it will be 10 away from the end (245), thus negating the color.