I want to perform a logical XOR with one color to produce another color. The multitude of functions dealing with html, rgb, binary conversions has my head spinning. In order to do a mathematical XOR, I must be dealing in numerical values, and I’m confused about what kind of results of functions will support this. Everything I’ve tried so far gives me a zero result that I know is not correct.

For example, I have a form object that is a rectangle of a given color, say “00FF00” (green). If I XOR it with the value “FFFFFF” it will flip every bit in the original, yielding “FF00FF”. This trivial example is easily solved without math, but I want to be able to take any original color and XOR it with any 3 byte value and see what I get. I just don’t know what format I need to use in my arguments to make it actually work, and produce a value that I can plug into a color parameter in some object.

Basically like this: NewColor = OldColor XOR MyMask.

The documentation for xor just talks about doing boolean operations with it, but I have confirmed that it does indeed perform bitwise binary operations on a value, which is what I want to do with that big color-defining number to yield a different color-defining number.