ImagerColor.mesa
Michael Plass, August 1, 1983 11:19 am
Last Edited by: Stone, February 10, 1984 4:47:16 pm PST
Last Edited by: Pier, January 19, 1984 2:21 pm
DIRECTORY
ImagerBasic USING [ConstantColor],
ColorModels USING [undefined, Calibration],
Rope USING [ROPE];
ImagerColor: CEDAR DEFINITIONS = BEGIN
black: ConstantColor;
white: ConstantColor;
-- All REAL values below should be in the range [0..1] except for undefined hues.
-- HSV is hue, saturation, value (hexacone model);
-- HSL is hue, saturation, lightness (double ended hexacone)
-- RGB is red, green, blue.
Defaulting the calibration assumes an "ideal" monitor device
undefined: REAL = ColorModels.undefined; -- (-1.0)
Calibration: TYPE = ColorModels.Calibration;
ConstantColor: TYPE = ImagerBasic.ConstantColor;
SampledColor: TYPE = ImagerBasic.SampledColor;
UndefinedColor: SIGNAL;
IntensityToColor: PROC [intensity: REAL, cal: Calibration ← NIL] RETURNS [ConstantColor];
HSVToColor: PROC [h, s, v: REAL, cal: Calibration ← NIL] RETURNS [ConstantColor];
HSLToColor: PROC [h, s, l: REAL, cal: Calibration ← NIL] RETURNS [ConstantColor];
RGBToColor: PROC [r, g, b: REAL, cal: Calibration ← NIL] RETURNS [ConstantColor];
-- The above 4 procedures will SIGNAL Runtime.BoundsFault for any argument
-- not in [0..1]; resuming the signal will perform arg ← MAX[0,MIN[1,arg]].
CIEToColor: PROC [x,y,Y: REAL, calibration: Calibration ← NIL] RETURNS [ConstantColor];
--CIE color system
NameToColor: PROC [name: Rope.ROPE, calibration: Calibration ← NIL] RETURNS [ConstantColor];
--Color naming system.
The hope is that this will be a set of "intuitive" descriptive names that people could type or select. A color name is composed of three properties, usually presented in order: lightness, saturation, hue. The current set of names for these properties is:
Lightness is one of: very dark, dark, medium, light, very light (default is medium)
Saturation is one of: weak, moderate, strong, vivid (default is vivid)
Hue is one of: red, orange, yellow, green, blue, purple, brown
You may also interpolate between the hue names as follows: red, orangish-red, red-orange, reddish-orange, orange... You may only interpolate between adjacent hues as defined in the list. Brown is actually a special case of orange, so you can interpolate from red to brown, and from brown to yellow.
There are three more hue names for achromatic colors: black, white and gray (grey).
Black and white are complete descriptions by themselves. Gray may have a valid lighness parameter (default is medium).
The following routines are inversion routines for the procedures above.
Note that for achromatic colors the hue parameters will be undefined.
ColorToIntensity: PROC[color: ConstantColor, cal: Calibration ← NIL] RETURNS[intensity: REAL];
ColorToHSV: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [h, s, v: REAL];
ColorToHSL: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [h, s, l: REAL];
ColorToRGB: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [r, g, b: REAL];
ColorToCIE: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [x,y,Y: REAL];
ColorToName: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [name: Rope.ROPE];
Sampled Color
The sampled color takes a pixel array and a color operator to define the color for each point on the page. The data for the pixel array is usually in an AIS file. You may construct your own pixel arrays and your own color operators.
AISToColor: PROC [aisName: Rope.ROPE, colorOperator: ColorOp ← IntensityOp, transform: ImagerBasic.Transformation ← default] RETURNS [ImagerBasic.Color];
If AIS file is a bitmap (0 bits/pixel) returns a BitmapColor otherwise returns a SampledColor
The photometry information for the AIS file will be hung on the data ref for the color op. Should we make a standard intensity operator that considers this information?
IntensityOp: ColorOp; --pixel values are linear intensities from 0 (black) to 2^n-1 (white)
BitmapToColor: PROC [bitmap: Bitmap, colorOperator: ColorOp ← BitmapOp, transform: ImagerBasic.Transformation ← default, transparent: BOOLEANFALSE] RETURNS [BitmapColor];
BitmapOp: ColorOp; --1=black, 0=white or transparent
MakeSampledColor: PROC[pixelArray: ImagerBasic.PixelArray, colorOperator: ColorOp, transform: ImagerBasic.Transformation ← default];
proposed color definition
default: ImagerBasic.Transformation;
Color: TYPE = REF ColorRep;
ColorRep: TYPE = RECORD[
SELECT tag: * FROM
constant => [x, y, Y: CARDINAL], -- CIE Chromaticity coordinates
sampled => [
pa: ImagerBasic.PixelArray, -- the array of samples
m: ImagerBasic.Transformation, -- transforms from pa to device coordinates
colorOperator: ColorOp -- maps samples into colors
],
bitmap => [ --bitmaps really are different: 1=black, 0=white or transparent
transparent: BOOLEAN,
pa: ImagerBasic.PixelArray, -- the array of bits
m: ImagerBasic.Transformation, -- transforms from pa to device coordinates
colorOperator: ColorOp -- maps bits into colors
],
special => [ref: REF],
ENDCASE
];
ConstantColor: TYPE = REF ColorRep[constant];
SampledColor: TYPE = REF ColorRep[sampled];
BitmapColor: TYPE = REF ColorRep[bitmap];
ColorOp: TYPE = REF OpRep;
OpRep: TYPE = RECORD [
class: ATOM,
do: PROC[data: REF] RETURNS [ConstantColor],
data: REF
];
Bitmap: TYPE = REF READONLY BitmapRep;
BitmapRep: TYPE = RECORD [
base: REF, -- pointer to bitmap bits
raster: CARDINAL, -- words per line
width: CARDINAL, -- width in bits
height: CARDINAL -- height in lines
];
-- (0,0) is at the upper left corner of the bitmap

NewBitmap: PROC[width,height: CARDINAL] RETURNS[Bitmap];
-- Returns a new bitmap object of given width and height

END.