[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

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

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?


176) Why doesn't GXxor produce mathematically-correct color values?



	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]



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 | Search | Web FAQs | Documents | RFC Index ]

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

Last Update December 02 2008 @ 00:13 AM

© 2008 FAQS.ORG. All rights reserved.