## Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z

# comp.windows.x Frequently Asked Questions (FAQ) 7/7Section - 176) Why doesn't GXxor produce mathematically-correct color values?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Sex offenders ]

Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 175) How do I create a transparent window?
Next Document: 177) Why does every color I allocate show up as black?
See reader questions & answers on this topic! - Help others by sharing your knowledge
```
When using GXxor you may expect that drawing with a value of black on a
background of black, for example, should produce white. However, the drawing
operation does not work on RGB values but on colormap indices. The color that
the resulting colormap index actually points to is undefined and visually
random unless you have actually filled it in yourself. [On many X servers Black
and White often 0/1 or 1/0; programs taking advantage of this mathematical
coincidence will break.]
If you want to be combining colors with GXxor, then you should be
allocating a number of your own color cells and filling them with your chosen
pre-computed values.
If you want to use GXxor simply to switch between two colors, then you
can take the shortcut of setting the background color in the GC (graphics
context) to 0 and the foreground color to a value such that when it draws over
red, say, the result is blue, and when it draws over blue the result is red.
This foreground value is itself the XOR of the colormap indices of red and
blue.

[Thanks to Chris Flatters (cflatter@zia.aoc.nrao.EDU) and Ken Whaley
(whaley@spectre.pa.dec.com), 2/91]

```

## User Contributions:

Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 175) How do I create a transparent window?
Next Document: 177) Why does every color I allocate show up as black?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
faq%craft@uunet.uu.net (X FAQ maintenance address)

Last Update March 27 2014 @ 02:12 PM