-- Last edited by Maureen Stone, February 10, 1984 4:18:42 pm PST -- Last edited by Frank Crow, April 16, 1984 3:23:27 pm PST ColorModels: CEDAR DEFINITIONS = { InvalidColor, Uninitialized: SIGNAL; undefined: REAL = -1; HSVToRGB: PROC[h, s, v: REAL] RETURNS[r, g, b: REAL]; RGBToHSV: PROC[r, g, b: REAL] RETURNS[h, s, v: REAL]; HSLToRGB: PROC[h, s, l: REAL] RETURNS[r, g, b: REAL]; RGBToHSL: PROC[r, g, b: REAL] RETURNS[h, s, l: REAL]; Real0: TYPE = REAL _ 0; Matrix3: TYPE = ARRAY [0..3) OF Row3; Row3: TYPE = ARRAY [0..3) OF Real0; Column3: TYPE = ARRAY [0..3) OF Real0; Calibration: TYPE = REF CalibrationRec; CalibrationRec: TYPE=RECORD [ toCIE: Matrix3, --rgb to cie matrix toRGB: Matrix3, --cie to rgb matrix yScale: REAL ]; InitCIE: PROC[xr,yr,xg,yg,xb,yb: REAL, whiteY: REAL _ 1.0] RETURNS [calibration: Calibration]; PhosphorType: TYPE = ATOM; -- $ConracLP, $HitachiLP, etc. GetPhosphorCalibration: PROC[type: PhosphorType _ $DefaultLP] RETURNS [calibration: Calibration]; RegisterPhosphorCalibration: PROC[xr,yr,xg,yg,xb,yb: REAL, type: PhosphorType]; GetDefaultValues: PROC[type: PhosphorType] RETURNS[xr,yr,xg,yg,xb,yb: REAL]; SetDefaultValues: PROC[xr,yr,xg,yg,xb,yb: REAL, type: PhosphorType]; CIEToRGB: PROC[x,y, Y: REAL, calibration: Calibration] RETURNS[r, g, b: REAL]; GetMaxY: PUBLIC PROC[x,y: REAL, calibration: Calibration] RETURNS[Y: REAL]; RGBToCIE: PROC[r, g, b: REAL, calibration: Calibration] RETURNS [x,y, Y: REAL]; }. ColorModels.mesa - Conversion routines between color models Copyright c 1984 by Xerox Corporation. All rights reserved. -- Last Edited by: Pier, January 18, 1984 12:54 pm The following four procedures convert between (hue, saturation, value) or (hue, saturation, lightness) and (red, green, blue). All values should be in the range [0..1] except when undefined undefined values: RGB: None HSV: If s=0 then h is undefined (color is a gray depending on v) If v=0 then h and s are undefined (color is black) HSL: If s=0 then h is undefined (color is a gray depending on l). If l=1 then h is undefined and s=0 (color is white) If l=0 then h is undefined and s=0 (color is black) --HSV hexacone model. HSL double hexacone model. The following procedures convert between (red, green, blue) and (x,y) chromaticity coordinates. Initialize the transform with x,y for red, green blue plus range for Y. CIEToRGB and RGBToCIE will signal Uninitialized if InitCIE has not been called These values are not guarenteed to stay in the range [0..1] unless the following is true: whiteY is set to 1.0 For CIEToRGB, Y <= GetMaxY[x,y] whiteY is the maximum range for Y. Traditionally 100, 1.0 is more compatible with the rest of the models here. This model is suitable for cie coordinates from a monitor and is relative to the monitor's white point. We need to define the (x,y) value for white to get absolute cie. In other words, if the white point of the monitor matches the CIE standard illuminant, this is enough. Otherwise we need to compensate that. may return a value outside of monitor's gamut For CIEToRGB, if Y <= GetMaxY[x,y], then the color is inside the monitors gamut. ʽ˜IprocšÏi Ïc1™<šœ Ïmœ1™™>šž™Kšœ ™ šœ@™@Kšœ2™2—šœA™AKšœ3™3Kšœ4ž™5——Kšœ œ˜$Kšœ  œ˜—Kš Ïnœ œ  œ œ  œ˜5š ¡œ œ  œ œ  œ˜5Kšœ™—Kš ¡œ œ  œ œ  œ˜5š ¡œ œ  œ œ  œ˜5Kšœ™Kšœ_™_KšœH™HKš¡œ¡œ9™N™YK™K™K™—Jšœ œ œ˜Jšœ  œ œ œ˜%Jšœ œ œ œ˜#Jšœ  œ œ œ˜&Kšœ  œ œ˜'šœ œ œ˜Kšœž˜#Kšœž˜#Kšœ ˜ K˜——š ¡œ œ œ  œ œ˜^Kšœ©™©—Kšœ œ œž˜;Kš¡œ œ" œ˜aKš¡œ œ œ˜OKš¡œ œ œ œ˜LKš¡œ œ œ˜Dš ¡œ œ œ œ œ  œ˜NKšœ-™-—š ¡œ œ œ œ œ œ˜KK™P—Kš ¡œ œ  œ œ œ œ˜OKšœ˜J˜—…—®û