adp@csug.cs.reading.ac.uk (David Dawkins) (11/13/90)
Hi there. I am having real problems trying to deal with colour and grayscales ( the whole damn kaboodle ) in NeWS. My colleague and I are trying to produce simple pie charts - that's easy. The difficult part is trying to gain control over the colours that are used, or even trying to use just gray-scaling. We understand the colour models used ( I think - I've done a bit of colour stuff in Xlib) , but we're buggered if we can get a canvas to come up that we have explicitly set the colour on. We are beginning to think that the whole idea of colour in NeWS is just a sick joke, and that it is all in the hands of the server, which is a mean and nasty sadist. Please, somebody show us otherwise. Seriously, it's really important that we get a handle on this thing real soon. Many thanks in advance, Dave and Al. ---------------------------------------------------------------------------- David J Dawkins | Use the following email address (mine is temp. screwed!) Reading University | adp@uk.ac.reading.cs.csug OR United Kingdom | adp%uk.ac.reading.cs.csug@uk.ac.nfs.net-relay
seah@ee.rochester.edu (David Seah) (11/21/90)
In article <1990Nov13.094100.18896@csug.rdg.ac.uk> adp@csug.cs.reading.ac.uk (David Dawkins) writes: >Hi there. > >I am having real problems trying to deal with colour and grayscales ( the whole >damn kaboodle ) in NeWS. My colleague and I are trying to produce simple >pie charts - that's easy. The difficult part is trying to gain control over >the colours that are used, or even trying to use just gray-scaling. We >understand the colour models used ( I think - I've done a bit of colour stuff >in Xlib) , but we're buggered if we can get a canvas to come up that we have >explicitly set the colour on. > >We are beginning to think that the whole idea of colour in NeWS is just a >sick joke, and that it is all in the hands of the server, which is a mean >and nasty sadist. Ditto! I must admit, though, that I'm a newcomer to the world of NeWS, so please bear with me. I've been trying to do the same thing for a few days now. Looking through the NeWS Programmer's Guide Chapter 9 and 10, I think I've been able to define the Visualtype, Colormaptype and Colorsegmenttypes, but I can't seem to get the (*@#$#* canvases to recognize any colors I've set. --- code follows --------------------------------------------------------- % GetVisual: number => visualtype % % Attempts to return the desired VisualType, which determines % how colormaps are handled. (pg 255, NeWS Programmer's Guide) % If visualtype can't be allocated, GetVisual will abort the program. % % Stack in: integer [0 to 5] % % Stack out: visualtype [one of StaticGray, GrayScale, StaticColor, % PseudoColor, TrueColor, DirectColor] % % /GetVisual { true framebuffer /VisualList get {dup /Class get 3 index eq {exch pop false exit} if pop} forall {console (*** Framebuffer can't allocate that VisualType.\n) fprintf quit} if exch pop } def /MyVisual % get PseudoColor Visual from framebuffer 3 GetVisual def /MyColorMap % make a blank colormap for canvas MyVisual createcolormap def % try to allocate a grayscale colormap..doesn't work %0 .004 1 {dup dup rgbcolor dup MyColorMap exch createcolorsegment % 0 3 -1 roll putcolor} for % Create canvas with associated Visual and Colormap /MyCanvas framebuffer MyVisual MyColorMap newcanvas def 0 0 200 200 rectpath MyCanvas reshapecanvas MyCanvas /Mapped true put MyCanvas /Transparent false put MyCanvas setcanvas --- end of code fragment ------------------------------------------------ I ran this through psh executive and checked that the Colormap was created (MyColorMap /Entries get ==). I checked to see that MyCanvas and MyColorMap were the same (MyCanvas /Colormap get MyColorMap eq ==) I manually created a few colors (MyColorMap .12 .23 .34 rgbcolor 0 createcolorsegment pop), but the color entries did not appear in the ColorMap. The "for" line up there originally just called createcolorsegment and popped off the returned colorsegment. Inspection of the color segment indicated that the color had indeed been assigned. I tried adding the putcolor to see if that would link the map and colorsegment together (seemed redundant to me), but got the error "invalid access" on the putcolor. Sample code to correctly generate a colormap under NeWS would be muchly appreciated! --- Dave Seah | Analog Design Automation Research Group | seah@ee.rochester.edu | Graphics User Interface Dude | AO: AFC DaveS ^..^ +-----------------------------------------------------------------+ yargh! | University of Rochester, Department of Electrical Engineering |