DIRECTORY Basics USING [BITSHIFT], Rope USING [ROPE], IO USING [PutRope, PutF, STREAM], ViewerIO USING [CreateViewerStreams], Graphics USING [Context], QuickViewer USING [BuildViewer], ImagerColorUtilities USING [SetNamedColor, SetRGBColor, Show8BitMap, LoadStd8BitMap, Rotate8BitMap, Load8BitRampMap, SetClipRectangle, FillRectangle, FillScreenTrap, DrawLine, ShowRope, SetDevice, GetAISFile, Get3AISFiles, PutAISFile, PutFastAISFile, Put3AISFiles], Imager USING [Context, Pair, SpecialOp], ImagerBasic USING [IntRectangle], ImagerDisplay USING [DisplayData], ImagerPixelMapsExtras USING [DrawLine, DrawBltLine], ConstantColors USING [ColorToName, HSLToColor], ColorNames USING [HSLToRope]; ImagerColorTestMain: CEDAR PROGRAM IMPORTS Imager, ConstantColors, ColorNames, IO, ViewerIO, QuickViewer, ImagerPixelMapsExtras, Basics, ImagerColorUtilities = BEGIN displayContext: Imager.Context _ NIL; contexts: ARRAY [0..4) OF Imager.Context _ ALL[NIL]; contextMax: NAT _ 4; contextCount: NAT _ 0; in, out: IO.STREAM; -- I/O to log viewer nullRectangle: ImagerBasic.IntRectangle _ [0, 0, 0, 0]; activeButton: ATOM; NameColor: PROC [color: Rope.ROPE] ~ { ImagerColorUtilities.SetNamedColor[color]; }; RGBColor: PROC [r, g, b: REAL] ~ { ImagerColorUtilities.SetRGBColor[r, g, b]; }; HSLToName: PROC [h, s, l: REAL] ~ { name: Rope.ROPE; name _ ConstantColors.ColorToName[ConstantColors.HSLToColor[h, s, l]]; IO.PutRope[out, name]; IO.PutF[out, "\n"]; }; HSLToLongName: PROC [h, s, l: REAL, levels: NAT] ~ { name: Rope.ROPE; name _ ColorNames.HSLToRope[h, s, l, levels]; IO.PutRope[out, name]; IO.PutF[out, "\n"]; }; Load8BitMap: PROC [] ~ { ImagerColorUtilities.LoadStd8BitMap[]; }; Rotate8BitMap: PROC [duration: NAT] ~ { -- rotates color map without moving zeroth entry ImagerColorUtilities.Rotate8BitMap[duration]; }; Show8BitMap: PROC [] ~ { ImagerColorUtilities.Show8BitMap[]; }; Load8BitRampMap: PROC [r1, g1, b1, r2, g2, b2, exponent: REAL] ~ { ImagerColorUtilities.Load8BitRampMap[r1, g1, b1, r2, g2, b2, exponent]; }; ClipRectangle: PROC [x, y, w, h: REAL] ~ { ImagerColorUtilities.SetClipRectangle[x, y, w, h]; }; FillRectangle: PROC [x, y, w, h: REAL] ~ { ImagerColorUtilities.FillRectangle[x, y, w, h]; }; FillTrap: PROC [top, bottom, leftTop, leftBot, rightTop, rightBot: INTEGER, color: NAT] ~ { ImagerColorUtilities.FillScreenTrap[top, bottom, leftTop, leftBot, rightTop, rightBot, color]; }; DrawLine: PROC [pt1, pt2: Imager.Pair, width: REAL] ~ { ImagerColorUtilities.DrawLine[pt1, pt2, width]; }; LineTest: PROC[color: CARDINAL, length, times: NAT] ~ { ax, ay, bx, by, xOffset, yOffset: INTEGER; displayData: ImagerDisplay.DisplayData _ NARROW[displayContext.data, ImagerDisplay.DisplayData]; logBitsPerPixel: NAT _ displayData[0].refRep.lgBitsPerPixel; mapLength: NAT _ Basics.BITSHIFT[1, Basics.BITSHIFT[1, logBitsPerPixel]]; xMax: NAT _ displayData[0].fSize; yMax: NAT _ displayData[0].sSize; IF length > yMax THEN length _ yMax; xOffset _ (xMax - length) / 2; yOffset _ (yMax - length) / 2; FOR i: NAT IN [0..times) DO FOR j: NAT IN [0..length] DO ax _ j + xOffset; ay _ length + yOffset; bx _ length + xOffset; by _ length - j + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawLine[displayData[0], [ax, ay], [bx, by], color]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ length + xOffset; ay _ length - j + yOffset; bx _ length - j + xOffset; by _ 0 + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawLine[displayData[0], [ax, ay], [bx, by], color]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ length - j + xOffset; ay _ 0 + yOffset; bx _ 0 + xOffset; by _ j + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawLine[displayData[0], [ax, ay], [bx, by], color]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ 0 + xOffset; ay _ j + yOffset; bx _ j + xOffset; by _ length + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawLine[displayData[0], [ax, ay], [bx, by], color]; ENDLOOP; ENDLOOP; }; BltLineTest: PROC[color: CARDINAL, length, times: NAT] ~ { ax, ay, bx, by, xOffset, yOffset: INTEGER; displayData: ImagerDisplay.DisplayData _ NARROW[displayContext.data, ImagerDisplay.DisplayData]; logBitsPerPixel: NAT _ displayData[0].refRep.lgBitsPerPixel; mapLength: NAT _ Basics.BITSHIFT[1, Basics.BITSHIFT[1, logBitsPerPixel]]; xMax: NAT _ displayData[0].fSize; yMax: NAT _ displayData[0].sSize; IF length > yMax THEN length _ yMax; xOffset _ (xMax - length) / 2; yOffset _ (yMax - length) / 2; FOR i: NAT IN [0..times) DO FOR j: NAT IN [0..length] DO ax _ j + xOffset; ay _ length + yOffset; bx _ length + xOffset; by _ length - j + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawBltLine[displayData[0], [ax, ay], [bx, by], color, [xor, null]]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ length + xOffset; ay _ length - j + yOffset; bx _ length - j + xOffset; by _ 0 + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawBltLine[displayData[0], [ax, ay], [bx, by], color, [xor, null]]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ length - j + xOffset; ay _ 0 + yOffset; bx _ 0 + xOffset; by _ j + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawBltLine[displayData[0], [ax, ay], [bx, by], color, [xor, null]]; ENDLOOP; FOR j: NAT IN [0..length] DO ax _ 0 + xOffset; ay _ j + yOffset; bx _ j + xOffset; by _ length + yOffset; color _ (color MOD mapLength) + 1; ImagerPixelMapsExtras.DrawBltLine[displayData[0], [ax, ay], [bx, by], color, [xor, null]]; ENDLOOP; ENDLOOP; }; ShowRope: PROC[x, y: REAL, rope: Rope.ROPE, fontRope: Rope.ROPE _ NIL, size: REAL _ .008] ~ { ImagerColorUtilities.ShowRope[x, y, rope, fontRope, size]; }; SetDevice: PROC[deviceType: ATOM, box, box2: ImagerBasic.IntRectangle, pinned: BOOLEAN] ~{ displayContext _ ImagerColorUtilities.SetDevice[deviceType, box, box2, pinned]; }; RecoverContext: PROC[contextNumber: NAT] ~ { displayContext _ contexts[contextNumber]; }; MoveOverlayTo: PROC[x, y: NAT] ~ { refX: REF INTEGER _ NEW[INTEGER _ x]; refY: REF INTEGER _ NEW[INTEGER _ y]; data: LIST OF REF ANY _ LIST[refX, refY]; [] _ Imager.SpecialOp[displayContext, $MoveOverlay, data]; }; SwitchBuffers: PROC[] ~ { [] _ Imager.SpecialOp[displayContext, $SwitchBuffers, NIL]; }; GetAISFile: PUBLIC PROC[fileName: Rope.ROPE, xOffSet, yOffSet: INTEGER _ 0] ~ { ImagerColorUtilities.GetAISFile[fileName, xOffSet, yOffSet]; }; Get3AISFiles: PUBLIC PROC[redFile, greenFile, blueFile: Rope.ROPE, xOffSet, yOffSet: INTEGER _ 0] ~ { ImagerColorUtilities.Get3AISFiles[redFile, greenFile, blueFile, xOffSet, yOffSet]; }; PutAISFile: PUBLIC PROC[fileName: Rope.ROPE] ~ { ImagerColorUtilities.PutAISFile[fileName]; }; PutFastAISFile: PUBLIC PROC[fileName: Rope.ROPE] ~ { ImagerColorUtilities.PutFastAISFile[fileName]; }; Put3AISFiles: PUBLIC PROC[redFile, greenFile, blueFile: Rope.ROPE] ~ { ImagerColorUtilities.Put3AISFiles[redFile, greenFile, blueFile]; }; MenuHit: PROCEDURE[command: ATOM, x, y: REAL] = { SELECT command FROM $Button => activeButton _ NIL; $MoveDCB => { activeButton _ $MoveDCB; IO.PutF[out, "Button received\n"]; }; ENDCASE; }; ReDraw: PROCEDURE [dc: Graphics.Context] = { }; ShutDown: PROCEDURE [] = { IO.PutF[out, "Imager Color Test over -- Bye\n"]; -- say goodbye }; Init: PROCEDURE [] = { QuickViewer.BuildViewer[LIST[$Button, $MoveDCB], ReDraw, ShutDown, MenuHit, "ImagerColorTest"]; [in, out] _ ViewerIO.CreateViewerStreams["ImagerColorTest.log"]; -- initialize i/o viewer }; END. ÞImagerColorTestMain.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Authored by Frank Crow Last Edited by: Crow, November 29, 1984 5:12:33 pm PST ImagerBridge USING [SetViewFromGraphicsContext], ImagerBridge, $Boxes, $Circles, $Exes, $Octagons => drawMode _ command; $LeftButton, $LeftHeld => { pointList _ CONS[ [x, y], pointList]; SELECT drawMode FROM $Exes => DrawX[pointList.first, size, black]; $Boxes => DrawBox[pointList.first, size, black]; $Circles => DrawCircle[pointList.first, size, black]; $Octagons => DrawOct[pointList.first, size, black]; ENDCASE; }; $MiddleButton => DrawX[[x, y], size, black]; $RightButton => DrawCircle[[x, y], size, black]; $MiddleHeld => DrawX[[x, y], size, white]; $RightHeld => IF activeButton = $MoveDCB THEN { displayData: ImagerDisplay.DisplayData _ NARROW[contexts[0].data, ImagerDisplay.DisplayData]; displayData[0].sOrigin _ 50 + Real.FixI[-y]; displayData[0].fOrigin _ 100 + Real.FixI[x]; displayContext _ contexts[0]; PinMap[]; }; $LeftHeld => IF activeButton = $MoveDCB THEN { displayData: ImagerDisplay.DisplayData _ NARROW[contexts[1].data, ImagerDisplay.DisplayData]; displayData[0].sOrigin _ 50 + Real.FixI[-y]; displayData[0].fOrigin _ 100 + Real.FixI[x]; displayContext _ contexts[1]; PinOverlay[]; IO.PutF[out, "x = %g, y = %g\n", IO.int[displayData[0].fOrigin], IO.int[displayData[0].sOrigin]]; }; Ê Ú˜Jšœ™Jšœ Ïmœ1™™>Jšœ<™<—Jšžœ™J™ Jšœ,™,Jšœ0™0Jšœ+™+šœžœžœ™0Jšœ)žœ™BKšœ*™*Jšœ0™0Jšœ,™,Jšœ™Jšœ ™ J™—šœžœžœ™/Jšœ)žœ™BKšœ*™*Jšœ0™0Jšœ,™,Jšœ™Jšœ ™ Jšžœ™!JšœH™HJ™——Jšžœ˜J˜J˜—š œž œ˜-J˜J˜—š œž œ ˜Kšžœ6Ÿ˜FJ˜J˜—š œž œ˜šœžœ˜0Jšœ6˜6—JšœAŸ˜YJ˜J˜J˜—Jšžœ˜J˜—…—:-ò