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. 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]; NameToColor: PROC [name: Rope.ROPE, calibration: Calibration _ NIL] RETURNS [ConstantColor]; 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]; END. 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 Defaulting the calibration assumes an "ideal" monitor device --CIE color system --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. 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: BOOLEAN _ FALSE] 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 ÊK˜J™J™&J™7J™.J™šÏk ˜ Jšœ œ˜"Jšœ œ˜+Jšœœœ˜—Jšœ œ œ˜&Jšœ˜Jšœ˜JšÏcQ˜QJšž2˜2JšÏi<˜™>J™¬—™SJ™w—J™—J˜JšœG™GJšœE™EJš  œœ*œœ œ˜^Jš   œœ+œœ œ˜XJš   œœ+œœ œ˜XJš   œœ+œœ œ˜XJš   œœ+œœœœ˜VJš   œœ+œœ œ˜[J˜™ J™ê—š  œœœYœ™™J™]J™©—I2šœžE™[Jš   œœsœœœ™­Jšœž™4J™Jš œœn™„J™J™Jšœ,œœ ™@šœ œœ™šœ™Jšœœœž™@™ Jšœž™3Jšœž+™JJšœž™2J™—šœ ž?™KJšœ œ™Jšœž™0Jšœž+™JJšœž™/J™—Jšœœ™Jš™—J™—J˜Jšœœœ™-Jšœœœ™+Jšœ œœ™)Jšœ œœ™šœœœ™Jšœœ™ Jšœœœœ™,Jšœ™ J™—J™Jš&œœœœœœ œžœ œžœ œžœ œžœž3œ  œœœœ ž8™ƒJšžœ˜—…—8•