giguere@csg.UWaterloo.CA (Eric Giguere) (07/31/90)
I have an interesting problem to do with colour under X. My application would like to use the three primary colours (RGB) and the three complementary colours (CMY) while running under a Motif environment. Now I've played with the colourmaps and I've come to agree with the conclusion that altering the standard Motif colourmap is not a good thing. Not only does it make other applications look strange, but it can also confuse the user by removing all those 3D highlighting cues. So I was thinking: Motif does have the RGB colours around. Why not use dithering to simulate CMY? Has anyone tried this approach? Has it worked? Did you run into problems when drawing patterned lines on top of a dithered background? I'd appreciate any tips/insights you could give me as I'm not sure this is the way to go... -- Eric Giguere giguere@csg.UWaterloo.CA
john@acorn.co.uk (John Bowler) (07/31/90)
In article <1990Jul30.192516.5718@maytag.waterloo.edu> giguere@csg.UWaterloo.CA (Eric Giguere) writes: >I have an interesting problem to do with colour under X. My application >would like to use the three primary colours (RGB) and the three complementary >colours (CMY) while running under a Motif environment. Now I've played with >the colourmaps and I've come to agree with the conclusion that altering >the standard Motif colourmap is not a good thing. Not only does it make >other applications look strange, but it can also confuse the user by removing >all those 3D highlighting cues. > >So I was thinking: Motif does have the RGB colours around. Why not use >dithering to simulate CMY? Has anyone tried this approach? Has it worked? >Did you run into problems when drawing patterned lines on top of a dithered >background? It won't work. You don't get a full intensity cyan by mixing equal parts of green and blue - you get a half intensity cyan. This is probably not what you want. In principle you want a colour map with 8 colours (RGB,CMY,black,white) - then you can reach any point in the RGB colour cube with an appropriate dither. In practice it sounds like you have a small colour map (only 16 entries?) - if so then you are actually much better off with a static colour map which has the above 8 colours plus the (8) colours at the corners of the (25%,25%,25%),(75%,75%,75%) cube. If you run the standard mwm on this it will come up with acceptable colours; the two blue values (one in the menus, the other in the selected window title bar) come out the same (the colour (25%,25%,75%) to be precise), but the highlighting still works and all colours which need to contrast do so. The colour map in question has the property that it minimises the ``error'' in the representation of any colour in the rgb cube (where ``error'' is crudely defined as the distance in the RGB cube from the colour you want to the colour you get). It also allows applications which use primaries (RGB, CMY) to always get the primary without allocating a new colour map and applications which are prepared to do dithering work very well (even images display well if displayed using Floyd-Steinberg error diffusion). If you don't do this you have next to no chance with mwm on a PseudoColor visual - mwm allocates most of the colours and, guess what, they're all blue or grey (:-|). Using dithering is easy for all cases except drawing points and LineDoubleDash lines - just used FillOpaqueStippled with a 2x2 bitmap containing 0 and 1 values; one of:- 01 or 01 10 11 and set the foreground and background to appropriate colours. If using the above colour map the colours will probably be close enough for the eye to be fooled, so long as the background (also dithered...) contrasts sufficiently. However, I haven't tried this - I've only tried images (where the results were almost as good as with a dynamic colour map with colours selected by Heckbert's median cut algorithm). One approach which *doesn't* work on a 16 entry map is using the current standard colour map facility - at best it would only give you the 8 primary/secondary colours, but (anyway) the implementation of xstdcmap refuses to set up a ``best'' map on a 16 entry colour map. John Bowler (jbowler@acorn.co.uk)