ImagerColor.mesa
Copyright © 1984 Xerox Corporation. All rights reserved.
Doug Wyatt, November 3, 1984 3:52:54 pm PST
DIRECTORY
ImagerPixelArray USING [PixelArray],
ImagerTransformation USING [Transformation],
Rope USING [ROPE];
ImagerColor: CEDAR DEFINITIONS
~ BEGIN
Transformation: TYPE ~ ImagerTransformation.Transformation;
PixelArray: TYPE ~ ImagerPixelArray.PixelArray;
ROPE: TYPE ~ Rope.ROPE;
CIE: TYPE ~ RECORD[X, Y, Z: REAL]; -- CIE tristimulus values, Y = 1-f
Calibration: TYPE ~ REF CalibrationRep;
CalibrationRep:
TYPE ~
RECORD[
Xr, Xg, Xb, Yr, Yg, Yb, Zr, Zg, Zb: REAL, -- transforms rgb to XYZ
rX, rY, rZ, gX, gY, gZ, bX, bY, bZ: REAL -- transforms XYZ to rgb
];
RGB: TYPE ~ RECORD[r, g, b: REAL]; -- red, green, blue
HSV: TYPE ~ RECORD[h, s, v: REAL]; -- hue, saturation, value
HSL: TYPE ~ RECORD[h, s, l: REAL]; -- hue, saturation, lightness
CIEFromIntensity: PROC[REAL] RETURNS[CIE];
IntensityFromCIE: PROC[CIE] RETURNS[REAL];
CIEFromRGB: PROC[rgb: RGB, cal: Calibration ← NIL] RETURNS[CIE];
RGBFromCIE: PROC[cie: CIE, cal: Calibration ← NIL] RETURNS[RGB];
HSVFromRGB: PROC[RGB] RETURNS[HSV];
RGBFromHSV: PROC[HSV] RETURNS[RGB];
HSLFromRGB: PROC[RGB] RETURNS[HSL];
RGBFromHSL: PROC[HSL] RETURNS[RGB];
HSLFromName: PROC[ROPE] RETURNS[HSL];
NameFromHSL: PROC[hsl: HSL, level: NAT ← 3] RETURNS[ROPE];
Color: TYPE ~ REF ColorRep;
ColorRep:
TYPE ~
RECORD[
SELECT tag: *
FROM
constant => [cie: CIE], -- CIE tristimulus values
sampled => [
pa: PixelArray, -- the array of samples
um: Transformation, -- transforms from color to device coordinates
colorOperator: ColorOperator -- maps samples into colors
],
special => [ref: REF],
ENDCASE
];
ConstantColor: TYPE ~ REF ColorRep[constant];
SampledColor: TYPE ~ REF ColorRep[sampled];
SpecialColor: TYPE ~ REF ColorRep[special];
ColorOperator: TYPE ~ REF ColorOperatorRep;
ColorOperatorRep:
TYPE ~
RECORD[
SELECT tag: *
FROM
black => [clear: BOOL ← FALSE], -- from MakeSampledBlack
grayLinear => [sWhite, sBlack: REAL, map: SampleMap ← NIL],
grayDensity => [sWhite, sBlack, dBlack: REAL, map: SampleMap ← NIL],
grayVisual => [sWhite, sBlack: REAL, map: SampleMap ← NIL],
map => [SEQUENCE size: CARDINAL OF CIE],
separations => [SEQUENCE samplesPerPixel: NAT OF Separation],
ENDCASE
];
SampleMap: TYPE ~ REF SampleMapRep;
SampleMapRep: TYPE ~ RECORD[SEQUENCE size: CARDINAL OF REAL];
Separation: TYPE ~ REF SeparationRep;
SeparationRep: TYPE ~ RECORD[cie: CIE, sMax, sMin: REAL, map: SampleMap ← NIL];
black, white: READONLY ConstantColor; -- MakeGray[1], MakeGray[0]
MakeGray: PROC[f: REAL] RETURNS[ConstantColor];
MakeCIE: PROC[CIE] RETURNS[ConstantColor];
MakeSampledBlack:
PROC[
pa: PixelArray,
um: Transformation,
clear: BOOL ← FALSE
] RETURNS[SampledColor];
MakeSampledColor:
PROC[
pa: PixelArray,
um: Transformation,
colorOperator: ColorOperator
] RETURNS[SampledColor];
XOR: READONLY SpecialColor;
END.