<<>> <> <> <> <> <> <> <> <> <> <> <> << >> DIRECTORY Basics USING [BITAND, BITSHIFT, BITXOR, MoveWords, LongNumber], ColorRegistry, ColorRegistryProcs, Convert USING [AtomFromRope], ConvertUnsafe USING [ToRope], Commander USING [CommandProc, Register], ImagerBrick USING [BrickFromDotScreen, Brick], ImagerColor USING [CMYK, SpecialColor, ColorRep, ConstantColor, RGB, ColorFromRGB], ImagerColorPrivate USING [ColorFromStipple, RegisterNamedColor, namedColorTable], ImagerSample, IO, Real USING [Round], Rope USING [ROPE, Cat, Concat], SymTab USING [EachPairAction, Pairs], SF USING [Box, Vec, Size, SizeF]; ColorRegistryImpl: CEDAR PROGRAM IMPORTS Basics, Convert, ConvertUnsafe, Commander, ImagerBrick, ImagerColor, ImagerColorPrivate, ImagerSample, IO, Real, Rope, SF, SymTab EXPORTS ColorRegistryProcs ~ BEGIN ROPE: TYPE = Rope.ROPE; RGB: TYPE = ImagerColor.RGB; CMYK: TYPE ~ ImagerColor.CMYK; Brick: TYPE ~ ImagerBrick.Brick; Data: TYPE = ColorRegistry.Data; DataRec: TYPE = ColorRegistry.DataRec; DeviceSequence: TYPE = ColorRegistry.DeviceSequence; DeviceSequenceRec: TYPE = ColorRegistry.DeviceSequenceRec; ColorProc: TYPE = ColorRegistryProcs.ColorProc; <<>> <> <> <> <> <> <<>> <> Dither1: NAT = 0; --ImagerDitherContextImpl Dither2: NAT = 1; Dither4: NAT = 2; Dither8: NAT = 3; FullColor: NAT = 4; --ImagerFullColorContextImpl, usually defaults RGB <> ColorPlatemaker: NAT = 5; --ImagerPDImpl or Interpress implementation BWPlatemaker: NAT = 6; Raven300: NAT = 7; --Quoth and Tim's printer. Color400: NAT = 8; --ImagerPDImpl ColorVersatec: NAT = 9; Raven384: NAT = 10; BW400: NAT = 11; Versatec: NAT = 12; nDevices: NAT =13; RegisterStipple: PROC ~ { invert: ImagerColor.SpecialColor ~ ImagerColorPrivate.ColorFromStipple[0FFFFH, [xor, null]]; invert.name ¬ "Xerox/Research/Stipple/Invert"; ImagerColorPrivate.RegisterNamedColor[invert]; }; distinctType: ATOM = $Distinct; DistinctNames: TYPE = {black, gray, white, red, green, blue, yellow}; distinctColors: ARRAY DistinctNames OF ImagerColor.SpecialColor; RegisterDistinct: PROC [standard: ROPE] ~ { distinctNames: ARRAY DistinctNames OF ROPE ¬ [ black: "Black", gray: "Gray", white: "White", red: "Red", green: "Green", blue: "Blue", yellow: "Yellow"]; distinctRGB: ARRAY DistinctNames OF RGB ¬ [ --Color displays black: [0,0,0], gray: [0.5,0.5,0.5], white: [1,1,1], red: [1,0,0], green: [0.25,0.8,0.33], blue: [0.1,0.3,0.85], yellow: [1,1,0]]; dBWStipples: ARRAY DistinctNames OF WORD ¬ [ --Bitmap devices black: 177777B, gray: 55AAH, white: 0, red: 36E9H, green: 85A1H, blue: 0EBB5H, yellow: 8241H]; inverseBrick: PROC[b: WORD] RETURNS[ImagerBrick.Brick] = TRUSTED { RETURN[[maxSample: 1, sampleMap: ImagerSample.TileFromStipple[Basics.BITXOR[177777B, b]], phase: 0]]; }; FOR i: DistinctNames IN [FIRST[DistinctNames]..LAST[DistinctNames]] DO fullName: ROPE ¬ Rope.Cat["Xerox/", standard, "Distinct/", distinctNames[i]]; data: Data ¬ NEW[DataRec ¬ [id: Convert.AtomFromRope[distinctNames[i]], deviceValues: NEW[DeviceSequenceRec[nDevices]]]]; bwBrick: ImagerBrick.Brick ¬ [maxSample: 1, sampleMap: ImagerSample.TileFromStipple[dBWStipples[i]], phase: 0]; substitute: ImagerColor.ConstantColor ¬ MakeSpecialColor[ type: $BitmapTile, data: LIST[ NEW[ImagerBrick.Brick ¬ bwBrick], NEW[ImagerSample.Function ¬ [null, null]] ], name: fullName, substitute: ImagerColor.ColorFromRGB[distinctRGB[i]] ]; <> <> data.deviceValues[Dither4] ¬ data.deviceValues[Dither8] ¬ NEW[NAT ¬ ORD[i]]; data.deviceValues[Dither1] ¬ data.deviceValues[Dither2] ¬ NEW[ImagerBrick.Brick ¬ inverseBrick[dBWStipples[i]]]; distinctColors[i] ¬ MakeSpecialColor[type: distinctType, name: fullName, data: data, substitute: substitute]; ImagerColorPrivate.RegisterNamedColor[distinctColors[i]]; ENDLOOP; }; <> chipNDaleType: ATOM ¬ $ChipNDale; CDNames: TYPE ={undefLayer, shadeLayer, errorLayer, backGround, outline, selection, comment, blue, red, green, yellow, gray, initialColor, nullColor, commentPushedOut, gate, gatePushedOut}; cdColors: ARRAY CDNames OF ImagerColor.SpecialColor; RegisterChipNDale: PROC = { cdStrings: ARRAY CDNames OF LONG STRING ¬ [ undefLayer: "UndefLayer", shadeLayer: "ShadeLayer", errorLayer: "ErrorLayer", backGround: "BackGround", outline: "Outline", selection: "Selection", comment: "Comment", blue: "Blue", red: "Red", green: "Green", yellow: "Yellow", gray: "Gray", initialColor: "InitialColor", nullColor: "NullColor", commentPushedOut: "CommentPushedOut", gate: "Gate", gatePushedOut: "GatePushedOut"]; <<>> errorColor: RGB ¬ [1,0.75,1]; rgbs: ARRAY CDNames OF RGB ¬ [undefLayer: errorColor, shadeLayer: errorColor, errorLayer: [0.5,0.5,0.5], backGround: [1,1,1], outline: [0,0,0], selection: [1,1,1], comment: [0,0,0], blue: [0,1,1], red: [1,0,0], green: [0,1,0], yellow: [0.929, 0.929, 0.476], gray: [0.5,0.5,0.5], initialColor: [1,1,1], nullColor: [1,1,1], commentPushedOut: [0, 0, 0], gate: [1.0, 1.0, 0.0], gatePushedOut: [1.0, 1.0, 0.0]]; <> bwDisplayTiles: REF CDDisplayTiles ¬ NEW[CDDisplayTiles ¬ ALL [NIL]]; dither8DisplayTiles: REF CDDisplayTiles ¬ NEW[CDDisplayTiles ¬ ALL [NIL]]; dither4DisplayTiles: REF CDDisplayTiles ¬ NEW[CDDisplayTiles ¬ ALL [NIL]]; InitCDDisplayTiles[bw: bwDisplayTiles, dither4: dither4DisplayTiles, dither8: dither8DisplayTiles]; <> FOR i: CDNames IN [FIRST[CDNames]..LAST[CDNames]] DO fullName: ROPE ¬ Rope.Concat["Xerox/Research/ChipNDale/CD/", ConvertUnsafe.ToRope[cdStrings[i]]]; substitute: ImagerColor.ConstantColor ¬ MakeSpecialColor[type: $BitmapTile, data: LIST[ NEW[ImagerBrick.Brick ¬ bwDisplayTiles[i].tile], NEW[ImagerSample.Function ¬ bwDisplayTiles[i].function]], name: fullName, substitute: ImagerColor.ColorFromRGB[rgbs[i]]]; data: Data ¬ NEW[DataRec ¬ [id: Convert.AtomFromRope[ConvertUnsafe.ToRope[cdStrings[i]]], deviceValues: NEW[DeviceSequenceRec[nDevices]]]]; data.deviceValues[Dither4] ¬ dither4DisplayTiles[i]; data.deviceValues[Dither8] ¬ dither8DisplayTiles[i]; cdColors[i] ¬ MakeSpecialColor[type: chipNDaleType, name: fullName, data: data, substitute: substitute]; ImagerColorPrivate.RegisterNamedColor[cdColors[i]]; ENDLOOP; }; CMosBNames: TYPE ={ndif, pdif, pwel, nwel, pwelcont, nwelcont, pol, met, met2, ovg, cut, cut2, imp, bur, bond, ndifPushedOut, pdifPushedOut, metPushedOut, met2PushedOut, polPushedOut, nwelPushedOut, cutPushedOut, cut2PushedOut}; cmosbColors: ARRAY CMosBNames OF ImagerColor.SpecialColor; RegisterCMosB: PROC = { cmosbStrings: ARRAY CMosBNames OF LONG STRING ¬ [ ndif: "NDif", pdif: "PDif", pwel: "PWel", nwel: "NWel", pwelcont: "PWelCont", nwelcont: "NWelCont", pol: "Pol", met: "Met", met2: "Met2", ovg: "Ovg", cut: "Cut", cut2: "Cut2", imp: "Imp", bur: "Bur", bond: "Bond", ndifPushedOut: "NDifPushedOut", pdifPushedOut: "PDifPushedOut", metPushedOut: "MetPushedOut", met2PushedOut: "Met2PushedOut", polPushedOut: "PolPushedOut", nwelPushedOut: "NWelPushedOut", cutPushedOut: "CutPushedOut", cut2PushedOut: "Cut2PushedOut"]; errorColor: RGB ¬ [1,0.75,1]; rgbs: ARRAY CMosBNames OF RGB ¬ [ ndif: [0,1,0], pdif: [0,1,0], pwel: errorColor, nwel: [0.929, 0.929, 0.476], pwelcont: [0,1,0.5], nwelcont: [0,1,0.5], pol: [1,0,0], met: [0,1,1], met2: [0.714, 0, 0.714], ovg: [0.5,0.5,0.5], cut: [0,0,0], cut2: [0,0,0], imp: errorColor, bur: errorColor, bond: [1, 1, 0], ndifPushedOut: [0,1,0], pdifPushedOut: [0,1,0], metPushedOut: [0,1,1], met2PushedOut: [0.714, 0, 0.714], polPushedOut: [1,0,0], nwelPushedOut: [0.929, 0.929, 0.476], cutPushedOut: [0,0,0], cut2PushedOut: [0,0,0]]; bwDisplayTiles: REF CMosBDisplayTiles ¬ NEW[CMosBDisplayTiles ¬ ALL[NIL]]; dither8DisplayTiles: REF CMosBDisplayTiles ¬ NEW[CMosBDisplayTiles ¬ ALL[NIL]]; dither4DisplayTiles: REF CMosBDisplayTiles ¬ NEW[CMosBDisplayTiles ¬ ALL[NIL]]; InitCMosBDisplayTiles[bw: bwDisplayTiles, dither4: dither4DisplayTiles, dither8: dither8DisplayTiles]; FOR i: CMosBNames IN [FIRST[CMosBNames]..LAST[CMosBNames]] DO data: Data ¬ NEW[DataRec ¬ [id: Convert.AtomFromRope[ConvertUnsafe.ToRope[cmosbStrings[i]]], deviceValues: NEW[DeviceSequenceRec[nDevices]]]]; fullName: ROPE ¬ Rope.Concat["Xerox/Research/ChipNDale/CMosB/", ConvertUnsafe.ToRope[cmosbStrings[i]]]; substitute: ImagerColor.ConstantColor ¬ MakeSpecialColor [ type: $BitmapTile, data: LIST[ NEW[ImagerBrick.Brick ¬ bwDisplayTiles[i].tile], NEW[ImagerSample.Function ¬ bwDisplayTiles[i].function]], name: fullName, substitute: ImagerColor.ColorFromRGB[rgbs[i]]]; data.deviceValues[Dither8] ¬ dither8DisplayTiles[i]; data.deviceValues[Dither4] ¬ dither4DisplayTiles[i]; cmosbColors[i] ¬ MakeSpecialColor[type: chipNDaleType, name: fullName, data: data, substitute: substitute]; ImagerColorPrivate.RegisterNamedColor[cmosbColors[i]]; ENDLOOP; }; CMosBDisplayTiles: TYPE = ARRAY CMosBNames OF REF DisplayBrick; CDBrick: TYPE = ARRAY [0..4) OF CARDINAL; --brick, or'ed into a bitmap Display: TYPE = {bw, bit4, bit8}; DisplayBrick: TYPE = ColorRegistry.DisplayBrick; <> CDDisplayTiles: TYPE = ARRAY CDNames OF REF DisplayBrick; InitCDDisplayTiles: PROC[bw, dither4, dither8: REF CDDisplayTiles] = { --from CDVDraw DefineColor: PROC[layer: CDNames, brick: CDBrick, display: Display, function: ImagerSample.Function ¬ [or, null]] = { SELECT display FROM bw => bw[layer] ¬ BrickFromCDBrick[brick, 1, function]; bit4 => dither4[layer] ¬ BrickFromCDBrick[brick, 15, function]; bit8 => dither8[layer] ¬ BrickFromCDBrick[brick, 255, function]; ENDCASE => ERROR; }; greenColor: CARDINAL = 1; blueColor: CARDINAL = 4; backGroundColor: CARDINAL = 8; redColor: CARDINAL = 16; yellowColor: CARDINAL = 32; impBondColor: CARDINAL = 14; ditherColor: CARDINAL = 0; black: CARDINAL = 127; shadeColor: CARDINAL = 255; outlineColor: CARDINAL = 124; greyDither: CARDINAL = 177771B; gateColor: CARDINAL = 17; DefineColor[undefLayer, Checker8[ditherColor, ditherColor], bit8]; DefineColor[backGround, [backGroundColor, ditherColor, backGroundColor * 100h, ditherColor], bit8]; DefineColor[shadeLayer, [shadeColor, ditherColor, shadeColor, ditherColor], bit8]; DefineColor[errorLayer, [ditherColor, shadeColor, ditherColor, ditherColor], bit8]; DefineColor[outline, Checker8[outlineColor, outlineColor], bit8]; DefineColor[selection, Checker8[shadeColor, shadeColor], bit8]; DefineColor[comment, Checker8[black, black], bit8]; DefineColor[commentPushedOut, Checker8[black, ditherColor], bit8]; DefineColor[initialColor, Checker8[ditherColor, ditherColor], bit8, [null, null]]; DefineColor[nullColor, Checker8[ditherColor, ditherColor], bit8]; DefineColor[blue, Checker8[blueColor, blueColor], bit8]; --loc 4 DefineColor[red, Checker8[redColor, redColor], bit8]; --loc 16 DefineColor[green, Checker8[greenColor, greenColor], bit8]; --loc 1 DefineColor[yellow, Checker8[yellowColor, yellowColor], bit8]; --loc 32 DefineColor[gray, [greyDither, greyDither, greyDither, greyDither], bit8]; --loc 249 DefineColor[gate, Checker8[gateColor, gateColor], bit8]; DefineColor[gatePushedOut, Checker8[gateColor, ditherColor], bit8]; <> <> <> <> <> <> <> <> <> <> DefineColor[undefLayer, [0,0,0,0], bw]; DefineColor[backGround, [257,0,0,0], bw]; DefineColor[shadeLayer, [101H, 0, 0, 0], bw]; DefineColor[errorLayer, [101H, 0, 101H, 0], bw]; DefineColor[outline, [08888h, 04444h, 02222h, 01111h], bw]; DefineColor[selection, [03333H, 03333H, 0CCCCH, 0CCCCH], bw, [null, null]]; DefineColor[comment, [0ffffH, 0ffffH, 0ffffH, 0ffffH], bw]; DefineColor[commentPushedOut, [0ffffH, 0ffffH, 0ffffH, 0ffffH], bw]; DefineColor[initialColor, [0, 0, 0, 0], bw, [null, null]]; DefineColor[nullColor, [0,0,0,0], bw]; DefineColor[blue, [8888H, 2222H, 0, 0], bw]; DefineColor[red, [8888H, 4444H, 2222H, 1111H], bw]; DefineColor[green, [4444H, 1111H, 4444H, 1111H], bw]; DefineColor[yellow, [4444H, 0, 0, 0], bw]; DefineColor[gray, [146314B, 31463B, 146314B, 31463B], bw]; DefineColor[gate, [0CCCCH, 5555H, 6666H, 1111H], bw]; DefineColor[gatePushedOut, [0C0C0H, 0505H, 6060H, 0101H], bw]; }; InitCMosBDisplayTiles: PROC[bw, dither8, dither4: REF CMosBDisplayTiles] = { --CMosBImpl DefineColor: PROC[layer: CMosBNames, brick: CDBrick, display: Display, function: ImagerSample.Function ¬ [or, null]] = { SELECT display FROM bw => bw[layer] ¬ BrickFromCDBrick[brick, 1, function]; bit4 => dither4[layer] ¬ BrickFromCDBrick[brick, 15, function]; bit8 => dither8[layer] ¬ BrickFromCDBrick[brick, 255, function]; ENDCASE => ERROR; }; nDiffColor: CARDINAL = 1; pDiffColor: CARDINAL = 2; met1Color: CARDINAL = 4; met2Color: CARDINAL = 8; polyColor: CARDINAL = 16; nWellColor: CARDINAL = 32; pWellColor: CARDINAL = 64; impBondColor: CARDINAL = 14; ditherColor: CARDINAL = 0; black: CARDINAL = 127; -- 8 bit Color definitions DefineColor[ndif, Checker8[nDiffColor, nDiffColor], bit8]; DefineColor[pdif, Checker8[pDiffColor, pDiffColor], bit8]; DefineColor[met, Checker8[met1Color, met1Color], bit8]; DefineColor[met2, Checker8[met2Color, met2Color], bit8]; DefineColor[pol, Checker8[polyColor, polyColor], bit8]; DefineColor[nwel, Checker8[nWellColor, nWellColor], bit8]; DefineColor[pwel, Checker8[pWellColor, pWellColor], bit8]; DefineColor[cut, Checker8[black, black], bit8]; DefineColor[cut2, Checker8[black, met1Color], bit8]; DefineColor[nwelcont, Checker8[pDiffColor, met1Color], bit8]; DefineColor[pwelcont, Checker8[nDiffColor, met1Color], bit8]; DefineColor[ovg, Checker8[met1Color, met2Color], bit8]; DefineColor[bur, Checker8[black, ditherColor], bit8]; DefineColor[imp, [impBondColor, impBondColor, ditherColor, ditherColor], bit8]; DefineColor[bond, [impBondColor, impBondColor, ditherColor, ditherColor], bit8]; -- Pushed Out Colors DefineColor[ndifPushedOut, Checker8[nDiffColor, ditherColor], bit8, [or, null]]; DefineColor[pdifPushedOut, Checker8[pDiffColor, ditherColor], bit8, [or, null]]; DefineColor[metPushedOut, Checker8[met1Color, ditherColor], bit8, [or, null]]; DefineColor[met2PushedOut, Checker8[met2Color, ditherColor], bit8, [or, null]]; DefineColor[polPushedOut, Checker8[polyColor, ditherColor], bit8, [or, null]]; DefineColor[nwelPushedOut, Checker8[nWellColor, ditherColor], bit8, [or, null]]; DefineColor[cutPushedOut, Checker8[black, ditherColor], bit8, [or, null]]; DefineColor[cut2PushedOut, Checker8[black, ditherColor], bit8, [or, null]]; -- Black & White Colors DefineColor[cut, [7777H, 0BBBBH, 7777H, 0BBBBH], bw]; DefineColor[ndif, [4444H, 1111H, 4444H, 1111H], bw]; DefineColor[pdif, [5555H, 1111H, 4444H, 1111H], bw]; DefineColor[pwelcont, [0, 1111H, 4444H, 1111H], bw]; DefineColor[nwelcont, [2222H, 1111H, 4444H, 1111H], bw]; DefineColor[pol, [8888H, 4444H, 2222H, 1111H], bw]; DefineColor[met, [8888H, 2222H, 0, 0], bw]; DefineColor[met2, [8888H, 8888H, 2222H, 2222H], bw]; DefineColor[nwel, [4444H, 0, 0, 0], bw]; DefineColor[pwel, [2222H, 0, 0, 0], bw]; DefineColor[ovg, [4444H, 0EEEEH, 4444H, 0], bw]; DefineColor[cut2, [3333H, 0EEEEH, 3333H, 0EEEEH], bw]; DefineColor[bur, [4444H, 0EEEEH, 4444H, 0], bw]; DefineColor[imp, [2222H, 0, 2222H, 0], bw]; DefineColor[bond, [2222H, 0, 2222H, 0], bw]; -- Pushed Out Colors DefineColor[ndifPushedOut, [4040H, 0101H, 4040H, 0101H], bw]; DefineColor[pdifPushedOut, [5050H, 0101H, 4040H, 0101H], bw]; DefineColor[metPushedOut, [8080H, 0202H, 0, 0], bw]; DefineColor[met2PushedOut, [8080H, 0808H, 2020H, 0202H], bw]; DefineColor[polPushedOut, [8080H, 0404H, 2020H, 0101H], bw]; DefineColor[nwelPushedOut, [4040H, 0, 0, 0], bw]; DefineColor[cutPushedOut, [7070H, 00B0BH, 7070H, 00B0BH], bw]; DefineColor[cut2PushedOut, [3030H, 00E0EH, 3030H, 00E0EH], bw]; }; <<>> Checker8: PROC [col1, col2: CARDINAL] RETURNS[CDBrick] = { RETURN[[col1*256+col2, col2*256+col1, col1*256+col2, col2*256+col1]] }; BrickFromCDBrick: PROC [cdBrick: CDBrick, maxSample: CARDINAL, function: ImagerSample.Function ¬ [or, null]] RETURNS [displayBrick: REF DisplayBrick] ~ TRUSTED { <> <<1 => [min: [0,0], max: [4,16]], 15 => [min: [0,0], max: [4,4]],>> < [min: [0,0], max: [4,2]]; --would be 255>> box: SF.Box ¬ SELECT maxSample FROM 1 => [min: [0,0], max: [4,32]], 15 => [min: [0,0], max: [4,8]], ENDCASE => [min: [0,0], max: [4,4]]; --would be 255 bitsPerSample: NAT ¬ SELECT maxSample FROM 1 => 1, 15 => 4, ENDCASE => 8; --would be 255 tile: ImagerBrick.Brick ¬ [ maxSample: maxSample, sampleMap: ImagerSample.NewSampleMap[box: box, bitsPerSample: bitsPerSample], phase: 0]; newBrick: CDBrick; FOR i: INT IN [0..4) DO newBrick[i] ¬ LOOPHOLE[Basics.LongNumber[pair[hi: cdBrick[i], lo: cdBrick[i]]], CARDINAL]; ENDLOOP; Basics.MoveWords[ dst: LOOPHOLE[ImagerSample.GetBase[NARROW[tile.sampleMap]].word], src: LOOPHOLE[@newBrick], count: WORDS[CDBrick]]; displayBrick ¬ NEW[DisplayBrick ¬ [function: function, tile: tile]]; }; MakeSpecialColor: PROC [type: ATOM, name: ROPE, data: REF, substitute: ImagerColor.ConstantColor] RETURNS [ImagerColor.SpecialColor] ~ { RETURN[NEW[ImagerColor.ColorRep.constant.special ¬ [constant[special[type: type, name: name, data: data, substitute: substitute]]]]]; }; <> <> EnumerateColors: PUBLIC PROC [type: ATOM ¬ $All, colorProc: ColorProc] = { SELECT type FROM distinctType => FOR i: DistinctNames IN [FIRST[DistinctNames]..LAST[DistinctNames]] DO IF colorProc[distinctColors[i]] THEN EXIT; ENDLOOP; chipNDaleType => { FOR i: CDNames IN [FIRST[CDNames]..LAST[CDNames]] DO IF colorProc[cdColors[i]] THEN EXIT; ENDLOOP; FOR i: CMosBNames IN [FIRST[CMosBNames]..LAST[CMosBNames]] DO IF colorProc[cmosbColors[i]] THEN EXIT; ENDLOOP; }; $CD => FOR i: CDNames IN [FIRST[CDNames]..LAST[CDNames]] DO IF colorProc[cdColors[i]] THEN EXIT; ENDLOOP; $CMosB => FOR i: CMosBNames IN [FIRST[CMosBNames]..LAST[CMosBNames]] DO IF colorProc[cmosbColors[i]] THEN EXIT; ENDLOOP; $All => { EnumerateColors[distinctType, colorProc]; EnumerateColors[chipNDaleType, colorProc]; }; ENDCASE => ERROR; }; <<>> <<>> <> InitPrinterColors: PUBLIC PROC [deviceType, colorType: ATOM, forceNew: BOOLEAN ¬ FALSE] = { SetProc: TYPE = PROC[color: NAT] RETURNS[REF]; setDistinct: PROC[set: SetProc, di: NAT] = { FOR i: DistinctNames IN [FIRST[DistinctNames]..LAST[DistinctNames]] DO data: Data ¬ NARROW[distinctColors[i].data]; data.deviceValues[VAL[di]] ¬ set[ORD[i]]; ENDLOOP; }; setCD: PROC[set: SetProc, di: NAT] = { FOR i: CDNames IN [FIRST[CDNames]..LAST[CDNames]] DO data: Data ¬ NARROW[cdColors[i].data]; data.deviceValues[VAL[di]] ¬ set[ORD[i]]; ENDLOOP; }; setCMosB: PROC[set: SetProc, di: NAT] = { FOR i: CMosBNames IN [FIRST[CMosBNames]..LAST[CMosBNames]] DO data: Data ¬ NARROW[cmosbColors[i].data]; data.deviceValues[VAL[di]] ¬ set[ORD[i]]; ENDLOOP; }; getBitmapTile: PROC[cd: BOOLEAN, ci, scale: NAT, rotated: BOOLEAN ¬ FALSE] RETURNS[REF DisplayBrick] = { <> <> special: ImagerColor.SpecialColor ¬ IF cd THEN NARROW[cdColors[VAL[ci]].substitute] ELSE NARROW[cmosbColors[VAL[ci]].substitute]; data: LIST OF REF ~ NARROW[special.data]; bw: REF ImagerBrick.Brick ¬ NARROW[data.first]; function: REF ImagerSample.Function ~ NARROW[data.rest.first]; sm: ImagerSample.RasterSampleMap ¬ PDFromDisplay[NARROW[bw.sampleMap], scale, rotated]; RETURN[NEW[DisplayBrick ¬ [function: function­, tile: [maxSample: 1, sampleMap: sm, phase: 0]]]]; }; testDistinctData: Data ¬ NARROW[distinctColors[black].data]; testChipNDaleData: Data ¬ NARROW[cmosbColors[ndif].data]; SELECT deviceType FROM $Color400, $color400 => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[Color400]=NIL THEN { dColor400: DistinctPrinterColors ¬ [ black: [1,1,1,1], gray: [0.77,0.54,0.52,0], white: [0,0,0,0], red: [0,1,1,0], green: [0.75,0,1,0], blue: [1,0.4,0,0], yellow: [0,0,1,0]]; proc: SetProc = {RETURN[NEW[CMYK ¬ dColor400[VAL[color]]]]}; setDistinct[proc, Color400]; }; $ChipNDale => IF testChipNDaleData.deviceValues[Color400]=NIL THEN { cdTiles: REF CDColorPDTiles ¬ NEW[CDColorPDTiles ¬ ALL [NIL]]; cmosbTiles: REF CMosBColorPDTiles ¬ NEW[CMosBColorPDTiles ¬ ALL[NIL]]; cd: SetProc = {RETURN[cdTiles[VAL[color]]]}; cmosb: SetProc = {RETURN[cmosbTiles[VAL[color]]]}; InitCDColor400PDTiles[cdTiles]; setCD[cd, Color400]; InitCMosBColor400PDTiles[cmosbTiles]; setCMosB[cmosb, Color400]; }; ENDCASE => ERROR; $ColorVersatec, $colorversatec, $colorVersatec => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[ColorVersatec]=NIL THEN { dColorVersatec: DistinctPrinterColors ¬ [ black: [1,1,1,1], gray: [0,0,0,0.5], white: [0,0,0,0], red: [0,1,1,0], green: [0.5,0,1,0], blue: [1,0.25,0,0], yellow: [0,0,1,0]]; proc: SetProc = {RETURN[NEW[CMYK ¬ dColorVersatec[VAL[color]]]]}; setDistinct[proc, ColorVersatec]; }; $ChipNDale => IF testChipNDaleData.deviceValues[ColorVersatec]=NIL THEN { cdTiles: REF CDColorPDTiles ¬ NEW[CDColorPDTiles ¬ ALL [NIL]]; cmosbTiles: REF CMosBColorPDTiles ¬ NEW[CMosBColorPDTiles ¬ ALL[NIL]]; cd: SetProc = {RETURN[cdTiles[VAL[color]]]}; cmosb: SetProc = {RETURN[cmosbTiles[VAL[color]]]}; InitCDVersatecPDTiles[cdTiles]; setCD[cd, ColorVersatec]; InitCMosBVersatecPDTiles[cmosbTiles]; setCMosB[cmosb, ColorVersatec]; }; ENDCASE => ERROR; $Raven384, $raven384 => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[Raven384]=NIL THEN{ proc: SetProc = {RETURN[dRaven384[VAL[color]]]}; dRaven384: REF DistinctBWTiles ¬ InitDistinctBWTiles[5.656, TRUE]; --ask for rotated tiles setDistinct[proc, Raven384]; }; $ChipNDale => { cd: BOOLEAN ¬ TRUE; proc: SetProc = {RETURN[getBitmapTile[cd, color, 4, TRUE]]}; setCD[proc, Raven384]; cd ¬ FALSE; setCMosB[proc, Raven384]; }; ENDCASE => ERROR; $Raven300, $raven300 => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[Raven300]=NIL THEN{ proc: SetProc = { --convert from ImagerPD.Brick to ImagerBrick.Brick pd: Brick ¬ dRaven300[VAL[color]]­; RETURN[NEW[DisplayBrick ¬[function: [null,null], tile: [maxSample: pd.maxSample, sampleMap: pd.sampleMap, phase: pd.phase]]]]; }; dRaven300: REF DistinctBWTiles ¬ InitDistinctBWTiles[4.419, TRUE]; --ask for rotated tiles setDistinct[proc, Raven300]; }; $ChipNDale => { cd: BOOLEAN ¬ TRUE; proc: SetProc = {RETURN[getBitmapTile[cd, color, 4, TRUE]]}; setCD[proc, Raven300]; cd ¬ FALSE; setCMosB[proc, Raven300]; }; ENDCASE => ERROR; $BWPlatemaker, $bwplatemaker => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[BWPlatemaker]=NIL THEN{ proc: SetProc = { --convert from ImagerPD.Brick to ImagerBrick.Brick pd: Brick ¬ tiles[VAL[color]]­; RETURN[NEW[ImagerBrick.Brick ¬ [maxSample: pd.maxSample, sampleMap: pd.sampleMap, phase: pd.phase]]]; }; tiles: REF DistinctBWTiles ¬ InitDistinctBWTiles[11.312]; setDistinct[proc, BWPlatemaker]; }; $ChipNDale => { cd: BOOLEAN ¬ TRUE; proc: SetProc = {RETURN[getBitmapTile[cd, color, 10]]}; setCD[proc, BWPlatemaker]; cd ¬ FALSE; setCMosB[proc, BWPlatemaker]; }; ENDCASE => ERROR; $BW400, $bw400 => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[BW400]=NIL THEN { proc: SetProc = {RETURN[dBW400[VAL[color]]]}; dBW400: REF DistinctBWTiles ¬ InitDistinctBWTiles[6]; setDistinct[proc, BW400]; }; $ChipNDale => { cd: BOOLEAN ¬ TRUE; proc: SetProc = {RETURN[getBitmapTile[cd, color, 5]]}; setCD[proc, BW400]; cd ¬ FALSE; setCMosB[proc, BW400]; }; ENDCASE => ERROR; $Versatec, $versatec => SELECT colorType FROM $Distinct => IF testDistinctData.deviceValues[Versatec]=NIL THEN { proc: SetProc = {RETURN[dVersatec[VAL[color]]]}; dVersatec: REF DistinctBWTiles ¬ InitDistinctBWTiles[4]; setDistinct[proc, Versatec]; }; $ChipNDale => { cd: BOOLEAN ¬ TRUE; proc: SetProc = {RETURN[getBitmapTile[cd, color, 2]]}; setCD[proc, Versatec]; cd ¬ FALSE; setCMosB[proc, Versatec]; }; ENDCASE => ERROR; ENDCASE => RETURN; }; DistinctPrinterColors: TYPE = ARRAY DistinctNames OF CMYK; DistinctBWTiles: TYPE = ARRAY DistinctNames OF REF Brick; CDColorPDTiles: TYPE = ARRAY CDNames OF LIST OF REF ColorPDBrick; CMosBColorPDTiles: TYPE = ARRAY CMosBNames OF LIST OF REF ColorPDBrick; InitDistinctBWTiles: PROC [scale: REAL, rotate90: BOOLEAN ¬ FALSE] RETURNS [tiles: REF DistinctBWTiles] ~ { TileShape: TYPE ~ RECORD [box: SF.Box, phase: INTEGER]; GetGoodShape: PROC [box: SF.Box, phase: INTEGER] RETURNS [TileShape] ~ { size: SF.Vec ~ SF.Size[box]; IF size.s <= 0 OR size.f <= 0 THEN ERROR; WHILE phase < 0 DO phase ¬ phase + size.f ENDLOOP; IF (16 MOD NAT[size.s] = 0) AND (16 MOD NAT[size.f] = 0) AND ((NAT[phase]*(16/NAT[size.s])) MOD 16 = 0) THEN { <> RETURN [[box: [max: [16, 16]], phase: 0]] }; RETURN [[box: [max: size], phase: phase]]; }; TileValues: TYPE = RECORD [ppd, angle, shape, f: REAL]; dBWTileValues: ARRAY DistinctNames OF TileValues ¬ [ black: [1,45,0.45, 1], gray: [1, 45, 0.45, 0.5], white: [1,45,0.45, 0], --regular halftones red: [2, 135, 0, 0.65], green: [2, 45, 0, 0.35], --diagonal lines blue: [2, 45, 0.5, 0.8], yellow: [2, 45, 0.5, 0.2]]; --big dots tiles ¬ NEW[DistinctBWTiles]; FOR i: DistinctNames IN [FIRST[DistinctNames]..LAST[DistinctNames]] DO tv: TileValues ¬ dBWTileValues[i]; angle: REAL ¬ (IF rotate90 THEN tv.angle+90 ELSE tv.angle); --raven vs everything else brick: Brick ¬ ImagerBrick.BrickFromDotScreen[tv.ppd*scale,angle,tv.shape]; shape: TileShape ~ GetGoodShape[ImagerSample.GetBox[brick.sampleMap], brick.phase]; bitmap: ImagerSample.RasterSampleMap ~ ImagerSample.ObtainScratchMap[shape.box]; b: ImagerSample.SampleBuffer ~ ImagerSample.ObtainScratchSamples[SF.SizeF[shape.box]]; sample: CARDINAL ~ Real.Round[tv.f*(brick.maxSample+1)]; ImagerSample.Clear[bitmap]; FOR s: INTEGER IN [shape.box.min.s..shape.box.max.s) DO ImagerSample.GetTileSamples[tile: brick.sampleMap, phase: brick.phase, initIndex: [s, shape.box.min.f], buffer: b]; FOR j: INTEGER IN [0..b.length) DO b[j] ¬ IF sample > b[j] THEN 1 ELSE 0; ENDLOOP; ImagerSample.PutSamples[map: bitmap, initIndex: [s, shape.box.min.f], buffer: b]; ENDLOOP; ImagerSample.ReleaseScratchSamples[b]; tiles[i] ¬ NEW[Brick¬ [maxSample: 1, sampleMap: bitmap, phase: shape.phase]]; ENDLOOP; }; Stipple4: TYPE = PACKED ARRAY[0..4) OF [0..16); Stipple8: TYPE = PACKED ARRAY[0..8) OF [0..256); Stipple16: TYPE = PACKED ARRAY[0..16) OF CARDINAL; ColorPDBrick: TYPE = ColorRegistry.ColorPDBrick; <> Color1: PROC RETURNS [tile: Brick] = { tile ¬ PatternToPDBrick[NEW[Stipple4 ¬ [17B, 17B, 17B, 17B]]] }; Color4: PROC [i0, i1, i2, i3: [0..16)] RETURNS [tile: Brick] = { tile ¬ PatternToPDBrick[NEW[Stipple4 ¬ [i0, i1, i2, i3]]]; }; Color8: PROC [i0, i1, i2, i3, i4, i5, i6, i7: [0..256)] RETURNS [tile: Brick] = { tile ¬ PatternToPDBrick[NEW[Stipple8 ¬ [i0, i1, i2, i3, i4, i5, i6, i7]]]; }; ToTexture: PROC [pattern: REF ANY] RETURNS [texture: Stipple16] = { <<--tries to convert pattern to a texture stipple>> WITH pattern SELECT FROM s16: REF Stipple16 => texture ¬ s16­; s8: REF Stipple8 => FOR i: [0..8) IN [0..8) DO texture[i] ¬ texture[i+8] ¬ (256+1)*s8[i]; ENDLOOP; s4: REF Stipple4 => FOR i: [0..4) IN [0..4) DO texture[i] ¬ texture[i+4] ¬ texture[i+8] ¬ texture[i+12] ¬ s4[i]*1111H; ENDLOOP; ENDCASE => RETURN[Stipple16[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0FFFFH]]; -- error texture RETURN [texture] }; -- ToTexture InitCDColor400PDTiles: PROC[array: REF CDColorPDTiles] = { array[undefLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: magenta, tile: Color8[16, 16, 16, 16, 16, 16, 255, 16]]]]; array[shadeLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[64, 64, 64, 64, 255, 64, 64, 64]]]]; array[errorLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color8[32, 32, 255, 32, 32, 32, 32, 32]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color8[32, 32, 255, 32, 32, 32, 32, 32]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[32, 32, 255, 32, 32, 32, 32, 32]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color8[32, 32, 255, 32, 32, 32, 32, 32]]]]; array[outline] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color1[]]]]; array[comment] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color1[]]]]; array[blue] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[6, 12, 9, 3]]]]; array[red] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[9, 3, 6, 12]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[9, 3, 6, 12]]]]; array[green] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[12, 9, 3, 6]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[12+1, 9, 3+4, 6]]]]; array[yellow] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[15, 15, 15, 15]]]]; array[gray] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[03, 14B, 03, 14B]]]]; }; InitCDVersatecPDTiles: PROC[array: REF CDColorPDTiles] = { array[undefLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: magenta, tile: Color8[10H, 10H, 10H, 10H, 10H, 10H, 0FFH, 10H]]]]; array[shadeLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[40H, 40H, 40H, 40H, 0FFH, 40H, 40H, 40H]]]]; array[errorLayer] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color8[20H, 20H, 0FFH, 20H, 20H, 20H, 20H, 20H]]]]; array[outline] ¬ LIST[NEW[ColorPDBrick ¬ [toner: black, tile: Color1[]]]]; array[comment] ¬ LIST[NEW[ColorPDBrick ¬ [toner: black, tile: Color1[]]]]; array[blue] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[5, 0, 5, 0]]]]; array[red] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[5, 0, 5, 0]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[5, 0, 5, 0]]]]; array[green] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[0AH, 0, 0AH, 0]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0AH, 4, 0AH, 0]]]]; array[yellow] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0AH, 0AH, 3, 3]]]]; array[gray] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[12B, 5, 12B, 5]]]]; }; InitCMosBColor400PDTiles: PROC[array: REF CMosBColorPDTiles] = { --From CDPDPlotC400CMosB.cm and CMosBPDPlotImpl.mesa array[ndif] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[12, 9, 3, 6]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[12+1, 9, 3+4, 6]]]]; array[pwelcont] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[0, 6, 6, 0]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0, 6, 6, 0]]]]; array[nwelcont] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[51, 51, 102, 102, 204, 204, 153, 153]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color8[51, 51, 102, 102, 204, 204, 153, 153]]]]; array[pol] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[9, 3, 6, 12]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[9, 3, 6, 12]]]]; array[met] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[6, 12, 9, 3]]]]; array[cut] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color1[]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color1[]]]]; array[met2] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[24, 48, 96, 192, 129, 3, 6, 12]]]]; array[cut2] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[3, 6, 12, 9]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[3, 6, 12, 9]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[3, 6, 12, 9]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[3, 6, 12, 9]]]]; array[ovg] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[0, 48, 48, 252, 252, 48, 48, 0]]]]; array[nwel] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[1, 2, 4, 8]]]]; array[bur] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color8[0, 0, 0, 0, 0, 56, 56, 56]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[0, 0, 0, 0, 0, 56, 56, 56]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color8[0, 0, 0, 0, 0, 56, 56, 56]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color8[0, 0, 0, 0, 0, 56, 56, 56]]]]; array[pdif ] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[12, 9, 3, 6]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[12, 9, 3, 6]]]]; array[imp] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[15, 15, 15, 15]]]]; array[pwel] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color8[0, 0, 8, 4, 0, 0, 0, 0]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[0, 0, 8, 4, 0, 0, 0, 0]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color8[0, 0, 8, 4, 0, 0, 0, 0]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color8[0, 0, 8, 4, 0, 0, 0, 0]]]]; }; InitCMosBVersatecPDTiles: PROC[ array: REF CMosBColorPDTiles]= { --From CDPDPlotVersatecCMosB.cm and CMosBPDPlotImpl.mesa array[ndif] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[0AH, 0, 0AH, 0]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0AH, 4, 0AH, 0]]]]; array[pdif] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[8, 2, 4, 1]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[8, 6, 4, 1]]]]; array[nwel] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0, 6, 0, 0]]]]; array[pwel] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[0FH, 0FH, 0, 0]]]]; array[pwelcont] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[2, 2, 8, 0]]], NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[0, 0, 0, 8]]]]; array[nwelcont] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[2, 2, 8, 0]]], NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[2, 2, 8, 0]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[0, 0, 0, 8]]]]; array[pol] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[5, 0, 5, 0]]], NEW[ColorPDBrick ¬ [toner: magenta, tile: Color4[5, 0, 5, 0]]]]; array[met] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color4[5, 0, 5, 0]]]]; array[cut] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[5, 0AH, 5, 0AH]]]]; array[met2] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[1, 2, 4, 8, 10H, 20H, 40H, 80H]]]]; array[cut2] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[0CH, 0CH, 3, 3]]]]; array[ovg] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: cyan, tile: Color8[0, 20H, 20H, 0F8H, 20H, 20H, 00H, 00H]]]]; array[bur] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: black, tile: Color4[2, 0, 8, 0]]]]; array[imp] ¬ LIST[ NEW[ColorPDBrick ¬ [toner: yellow, tile: Color4[0AH, 0AH, 3, 3]]]]; }; PatternToPDBrick: PROC [pattern: REF ANY] RETURNS [Brick] ~ TRUSTED { texture: Stipple16 ¬ ToTexture[pattern]; box: SF.Box ¬ [min: [0,0], max: [16,16]]; tile: Brick ¬ [ maxSample: 1, sampleMap: ImagerSample.NewSampleMap[box: box, bitsPerSample: 1, bitsPerLine: 16], phase: 0]; Basics.MoveWords[ dst: LOOPHOLE[ImagerSample.GetBase[NARROW[tile.sampleMap]].word], src: LOOPHOLE[@texture], count: WORDS[Stipple16]]; RETURN[tile]; }; PDFromDisplay: PROC [source: ImagerSample.RasterSampleMap, scale: NAT ¬ 1, rotate: BOOLEAN ¬ FALSE] RETURNS [sm: ImagerSample.RasterSampleMap] = { --rotate is for Ravens AccessBits: TYPE = PACKED ARRAY[0..16) OF BOOL; bits: NAT ¬ 16; lines: NAT ¬ 4; quit: BOOL ¬ FALSE; mask: CARDINAL ¬ 0FF00H; --a mask with the leftmost maskBits bits set maskBits: NAT ¬ 8; sb: ImagerSample.SampleBuffer; box: ImagerSample.Box; cdb: CDBrick; IF scale<1 THEN ERROR; <> TRUSTED { Basics.MoveWords[ dst: LOOPHOLE[@cdb], src: LOOPHOLE[ImagerSample.GetBase[source].word], count: WORDS[CDBrick]]; }; <<--reducing CDBrick is interesting because most CDBrick's are very simple>> <<--reduce height>> IF cdb[0]=cdb[2] AND cdb[1]=cdb[3] THEN { lines ¬ 2; IF cdb[0]=cdb[1] THEN lines ¬ 1 }; <<--reduce width >> WHILE maskBits>0 AND ~quit DO FOR line: NAT IN [0..lines) DO <<--compare the leftmost maskBits bits to the rightmost maskBits bits>> IF Basics.BITAND[cdb[line], mask]#Basics.BITSHIFT[cdb[line], 16-maskBits] THEN quit¬TRUE; ENDLOOP; IF ~quit THEN { bits ¬ maskBits; maskBits ¬ maskBits/2; mask ¬ Basics.BITSHIFT[mask, maskBits] } ENDLOOP; <<--build the map>> sb ¬ ImagerSample.NewSamples[bits*scale]; box ¬ IF rotate THEN [min: [0,0], max: [s: bits*scale, f: lines*scale]] ELSE [min: [0,0], max: [s: lines*scale, f: bits*scale]]; sm ¬ ImagerSample.NewSampleMap[box: box, bitsPerSample: 1]; ImagerSample.Clear[sm]; <<--loop through CDBrick>> FOR linePos: NAT IN [0..lines) DO <<--build one line>> ImagerSample.ClearSamples[sb]; FOR bitPos: NAT IN [0..bits) DO IF LOOPHOLE[cdb[linePos], AccessBits][bitPos] THEN ImagerSample.FillSamples[sb, 1, scale*bitPos, scale]; ENDLOOP; <<--store line and replicate it >> FOR i: NAT IN [0..scale) DO s: INTEGER ¬ IF rotate THEN 0 ELSE linePos*scale+i; f: INTEGER ¬ IF rotate THEN linePos*scale+i ELSE 0; delta: ImagerSample.Vec ¬ IF rotate THEN [s: 1, f: 0] ELSE [s: 0, f: 1]; ImagerSample.PutSamples[map: sm, initIndex: [s: s, f: f], delta: delta, buffer: sb]; ENDLOOP ENDLOOP; }; PrintCurrentNames: PUBLIC PROC [stream: IO.STREAM] ~ { printName: SymTab.EachPairAction = { IO.PutRope[stream, key]; IO.PutChar[stream, '\n]; }; [] ¬ SymTab.Pairs[ImagerColorPrivate.namedColorTable, printName]; }; PrintRegisteredColorsCommand: Commander.CommandProc ~ BEGIN <<[cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]>> stream: IO.STREAM ¬ cmd.out; IO.PutRope[stream, "Registered Colors:\n"]; PrintCurrentNames[stream]; msg ¬ "-- Done --" END; -- PrintRegisteredColors DoRegistration: PROC ~ { RegisterStipple[]; RegisterDistinct [NIL]; RegisterDistinct ["Research/"]; RegisterChipNDale[]; RegisterCMosB[]; }; DoRegistration[]; Commander.Register [key: "PrintRegisteredColors", proc: PrintRegisteredColorsCommand, doc: "Print the list of registered colors."]; END.