ColorTrixMap.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, March 20, 1986 2:26:50 pm PST
Procedures for accessing or modifying the color display color map.
DIRECTORY Imager, ImagerColorMap, ImagerTransformation, IO, Rope, Terminal;
ColorTrixMap: CEDAR DEFINITIONS
~ {
Gun: TYPE ~ ImagerColorMap.Gun;
Comp: TYPE ~ REF CompRep;
CompRep: TYPE ~ ARRAY Terminal.ChannelValue OF Terminal.ChannelValue;
Cmap: TYPE ~ REF CmapRep;
CmapRep: TYPE ~ ARRAY [0..3) OF Comp;
Storage/Retrieval/Allocation Operations
NewCmap: PROC RETURNS [Cmap];
Return newly allocated Cmap and its Comps.
Write: PROC [map: Cmap];
Set the color map of the color display to the input color map.
WriteEntry: PROC [i, r, g, b: NAT];
Write val to the color display color map's entry i.
JustWritten: PROC;
Inform waiting clients that color map is just written.
WaitTilNew: PROC;
Waits until the map is just written.
Read: PROC [out: Cmap ← NIL] RETURNS [Cmap];
Read the color map of the color display and return; use out if non-nil.
ReadEntry: PROC [map: Cmap, i: NAT] RETURNS [r, g, b: NAT];
Return the color display color map's entry i.
Save: PROC [in: Cmap, name: Rope.ROPE];
Save the color map in the specified file.
Load: PROC [name: Rope.ROPE, out: Cmap ← NIL] RETURNS [BOOL];
Read a color map from the specified file; return true iff successful.
If out is non-nil, load it with the color map, else write the map directly to the color display.
In the file text may precede the color map entries.
Each entry must consist of an index (ABS[index] < 256) and values for red, green and blue.
Each value must be in [0..255].
StreamLoad: PROC [s: IO.STREAM, out: Cmap ← NIL] RETURNS [BOOL];
As Load except a stream, rather than filename, is provided for input.
Copy: PROC [in: Cmap, out: Cmap ← NIL] RETURNS [Cmap];
Return a copy of the input color map; use out if provided, else allocate a new map.
CopyEntry: PROC [src: Cmap, isrc: NAT, dst: Cmap, idst: NAT];
Copy entry isrc from src to entry idst of dst.
SetEntry: PROC [in: Cmap, i, r, g, b: NAT];
Set the specified color map entry to be [r,g,b].
GetEntry: PROC [in: Cmap, i: NAT] RETURNS [r, g, b: NAT];
Return the specified color map entry.
Creation Operations
FuncProc: TYPE ~ PROC [i: NAT] RETURNS [NAT];
Function: PROC [rFunc, gFunc, bFunc: ColorTrixMap.FuncProc, out: Cmap ← NIL];
Apply the three functions to out, if non-nil, else directly to the display.
Mono: PROC [out: Cmap ← NIL];
Apply linear ramp from 0 through 255 to out, if non-nil, else directly to the display.
Gamma: PROC [gamma: REAL ← 2.2, out: Cmap ← NIL];
Apply gamma corrected grayscale to out, if non-nil, else directly to the display.
Ramp: PROC [i0, r0, g0, b0, i1, r1, g1, b1: NAT, out: Cmap ← NIL];
Apply ramp from i0 through i1 according to [r0, g0, b0] and [r1, g1, b1] to out, if non-nil, else directly to the display.
ClearColorMap: PROC [out: Cmap ← NIL];
Set all color map entries to zero of out, if non-nil, else of display.
FloodPrimary: PROC [gun: Gun, out: Cmap ← NIL];
Set all entries of the specified gun to full on, all other guns fully off; write to out if non-nil, else directly to the display.
PrimaryOnly: PROC [gun: Gun, out: Cmap ← NIL];
Set the specified gun to a normal grayscale, all other guns fully off; write to out if non-nil, else directly to the display.
Tents: PROC [nTents: NAT, out: Cmap ← NIL];
Apply nTents cycles of linear ramps to out if non-nil, else directly to the display.
Sin: PROC [nRCycles, nGCycles, nBCycles: REAL ← 1.0, out: Cmap ← NIL];
Apply nCycles sine oscillations to out if non-nil, else directly to the display.
Gauss: PROC [out: Cmap ← NIL];
Apply nCycles gaussian oscillations to out if non-nil, else directly to the display.
Modification Operations
NBits: PROC [in: Cmap, nBits: NAT, out: Cmap ← NIL];
Simulate nBits number of bits [0..8] to the input color map; write to out if non-nil, else directly to the display.
Cycle: PROC [map: Cmap, nCycle: INTEGER, red, grn, blu: BOOLTRUE] RETURNS [Cmap];
Cycle the colormap by the specified number of entries. Return the input map.
Arithmetic Operations
Scale: PROC [in: Cmap, s: REAL, out: Cmap ← NIL];
Apply s*in to out if non-nil, else directly to display.
Add: PROC [in: Cmap, a: INTEGER, out: Cmap ← NIL];
Apply in+a to out if non-nil, else directly to display.
CmScale: PROC [in1, in2: Cmap, out: Cmap ← NIL];
Apply in1*in2 to out, if non-nil, else directly to the display.
CmAdd: PROC [in1, in2: Cmap, out: Cmap ← NIL];
Apply in1+in2 to out, if non-nil, else directly to the display.
Compose: PROC [in1, in2: Cmap, out: Cmap ← NIL];
Apply in2[in1] to out, if non-nil, else directly to the display.
Interp: PROC [t: REAL, in1, in2: Cmap, out: Cmap ← NIL];
Apply (1.0-t)*in1+t*in2 to out, if non-nil, else directly to the display.
Random Creation Operations
Scramble: PROC [in: Cmap, out: Cmap ← NIL];
Scramble map's entries. Write to out if non-nil,. else directly to the display.
Rand: PROC [out: Cmap ← NIL];
Put arbitrary values into out, if non-nil, else directly into the display.
Miscellaneous Operations
WriteAndRelease: PROC [cm: Cmap];
Write the scratch color map to the display and release it.
ObtainCmap: PROC RETURNS [Cmap];
Obtain a scratch color map.
ReleaseCmap: PROC [cmap: Cmap];
Release the scratch color map.
Display Operations
Show: PROC [context: Imager.Context, cm: Cmap, x, y: INTEGER ← 0, w, h: INTEGER, label, border: BOOLTRUE];
Display the color map as three curves within the given context.
ShowComp: PUBLIC PROC [context: Imager.Context, c: Comp, x, y, w, h: INT, border: BOOLTRUE, label: Rope.ROPENIL];
Display a single color map component.
}.