How does XOR mode work?
XOR mode restores the colors if you do it twice. The Color argument when you enable XOR mode allows the system to calculate the pixel value you want to XOR with in a system-independent manner. In other words, if you know that the color on the screen is (predominantly) white, and you want to XOR with some value that changes that white to green and then back again, you have no way of calculating the appropriate pixel value to use to make those alternations. So, you tell us the two colors that you are interested in alternating when you draw and then we will calculate the appropriate pixel value for you taking into account the Color Model of the screen. Other colors will be changed in a random, but reversible manner as per the boolean XOR operation.