ConstantColors.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];
ConstantColors: 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;
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] RETURNS [ConstantColor];
--CIE color system
NameToColor: PROC [name: Rope.ROPE, cal: 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] RETURNS [x,y,Y: REAL];
ColorToName: PROC [color: ConstantColor, cal: Calibration ← NIL] RETURNS [name: Rope.ROPE];
END.