[comp.windows.x] question on using GC Functions for levels of overlap

greggw@iscnvx.uucp (William E. Gregg) (04/18/91)

Can anyone give me some ideas on drawing overlapping objects on the screen
in such a way that the colors indicate the level of overlap (i.e. single,
double, triple, ...).  I have a slow brute force version, but I am interested
in a technique that would work during the drawing of each object.  I have
been looking at the GC Functions (GXxor, GXand, etc) and thinking that there
must be a clever way to accomplish this.  I have 8 bitplanes, so potentially
256 different levels of overlap could be kept track of.

Thanks in advance,
Bill Gregg
greggw@iscnvx.lmsc.lockheed.com

klee@wsl.dec.com (Ken Lee) (04/19/91)

In article <1991Apr18.013051.24770@iscnvx.uucp>, greggw@iscnvx.uucp (William E. Gregg) writes:
|> Can anyone give me some ideas on drawing overlapping objects on the screen
|> in such a way that the colors indicate the level of overlap (i.e. single,
|> double, triple, ...).

Most college text books on raster graphics describe techniques for
setting up a colormap to do what you want.  The idea is to chose your
pixel values so that addition and subtraction do intelligent things.
These techniques were pretty popular in early CAD and image processing
applications, but are not well supported in many modern window systems
(other than X).

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (05/02/91)

> Can anyone give me some ideas on drawing overlapping objects on the
> screen in such a way that the colors indicate the level of overlap
> (i.e. single, double, triple, ...).  I have a slow brute force
> version, but I am interested in a technique that would work during
> the drawing of each object.  I have been looking at the GC Functions
> (GXxor, GXand, etc) and thinking that there must be a clever way to
> accomplish this.  I have 8 bitplanes, so potentially 256 different
> levels of overlap could be kept track of.

Ken Lee then replies

> Most college text books on raster graphics describe techniques for
> setting up a colormap to do what you want.  The idea is to chose your
> pixel values so that addition and subtraction do intelligent things.

Right.  Then all you need to do is describe how to draw something using
addition or subtraction instead of copy, OR, XOR, etc.  GXadd,
GXsubtract, etc, don't exist.

> These techniques were pretty popular in early CAD and image
> processing applications, but are not well supported in many modern
> window systems (other than X).

I'd say they're not supported at all in X.  If you want the equivalent
of GXadd, you have to GetImage the pictures back to the client, add
them there, and send them back to the server, or else do bit-by-bit
addition with XCopyPlane and plane-masks and such.  All alternatives
are ugly and likely to be slow.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

graeme@labtam.labtam.oz (Graeme Gill) (05/03/91)

In article <9105021410.AA18438@lightning.McRCIM.McGill.EDU>, mouse@lightning.mcrcim.mcgill.EDU (der Mouse) writes:
> > Ken Lee writes:
> > Can anyone give me some ideas on drawing overlapping objects on the
> > screen in such a way that the colors indicate the level of overlap
> > (i.e. single, double, triple, ...).
....
> I'd say they're not supported at all in X.  If you want the equivalent
> of GXadd, you have to GetImage the pictures back to the client, add
> them there, and send them back to the server, or else do bit-by-bit
> addition with XCopyPlane and plane-masks and such.  All alternatives
> are ugly and likely to be slow.
>
	The simplest idea is to allow up to 8 overlay planes, one per
pixel plane. The colour map is then set up so that it naturally gives
the correct colour for the sum of the planes present. To write to an overlay
plane simply set the plane mask to the appropriate plane and draw objects
as per usual. There is no need for a GXadd logical operation. This scheme
won't handle more than 8 overlapping objects of course.

	Graeme Gill
	Labtam Australia

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (05/05/91)

>>> Can anyone give me some ideas on drawing overlapping objects on the
>>> screen in such a way that the colors indicate the level of overlap
>>> (i.e. single, double, triple, ...).
>> I'd say they're not supported at all in X.  If you want the
>> equivalent of GXadd, you have to [...].
> The simplest idea is to allow up to 8 overlay planes, one per pixel
> plane.

Well yes, if you're willing to dedicate a whole bitplane to each
object, you can do anything you like with overlap.  I was assuming the
original poster wasn't satisfied with that approach; it uses up
exponential colormap space, rapidly getting entirely out of hand.

I may have been wrong in this assumption; thank you for pointing out
this tactic....

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu