DIRECTORY Basics, Imager, ImagerBasic, ImagerTransform, RealFns, Rope, Scaled, Font; ImagerTester: CEDAR PROGRAM IMPORTS Basics, Imager, ImagerTransform, Font, RealFns, Scaled = BEGIN Pair: TYPE ~ Imager.Pair; Context: TYPE ~ Imager.Context; FONT: TYPE ~ Imager.FONT; ROPE: TYPE ~ Rope.ROPE; mercuryPath: REF _ MercuryPath[ImagerTransform.Rotate[0]]; MercuryPath: PROC [m: ImagerBasic.Transformation] RETURNS [t: Imager.Trajectory] = { r: ImagerTransform.TransformationRec _ m.Contents; X: PROC[p: Pair] RETURNS [Pair] ~ { RETURN [[r.a*p.x + r.b*p.y + r.c, r.d*p.x + r.e*p.y + r.f]] }; Curve: PROC [a,b,c,d,e,f: REAL] ~ {t _ t.CurveTo[X[[a, b]], X[[c, d]], X[[e, f]]]}; t _ Imager.MoveTo[X[[192.0, 413.353]]]; Curve[237.5415, 425.809, 255.3458, 401.7666, 288.0, 399.5085]; Curve[297.9937, 398.8174, 308.0844, 403.6591, 318.0, 404.5501]; Curve[331.9086, 405.7998, 448.1434, 401.3464, 450.8684, 396.0001]; Curve[453.3393, 391.1521, 435.2951, 383.4805, 431.9999, 383.0218]; Curve[428.5259, 382.538, 410.233, 382.6307, 409.5, 378.0]; Curve[409.8045, 379.9238, 421.3876, 370.5168, 402.0001, 363.6874]; Curve[386.3301, 358.1678, 345.4535, 362.3779, 345.5, 359.9999]; Curve[345.4942, 360.2959, 368.3762, 359.2238, 372.0, 358.0435]; Curve[389.1935, 352.4433, 364.4147, 343.7253, 364.875, 336.0]; Curve[365.5193, 325.1856, 382.3762, 294.0994, 390.0, 285.675]; Curve[408.286, 265.4687, 417.344, 272.0564, 438.0001, 263.8696]; Curve[454.6547, 257.2686, 417.2523, 242.3468, 408.0, 243.5193]; Curve[383.1711, 246.6655, 383.3985, 232.3274, 366.0, 219.439]; Curve[352.0869, 209.1325, 366.6143, 208.1149, 372.0, 208.9024]; Curve[374.2727, 209.2348, 386.2989, 214.7218, 380.8284, 204.0]; Curve[378.6221, 199.6753, 364.5704, 185.5353, 360.0, 184.8125]; Curve[351.8828, 183.5287, 332.7219, 196.0891, 329.1539, 192.0]; Curve[321.1773, 182.8585, 343.6019, 183.1676, 340.0227, 174.0]; Curve[335.0409, 161.2398, 311.5035, 158.2857, 310.4737, 126.0]; Curve[310.1649, 116.3195, 313.5754, 76.22575, 312.75, 72.0]; Curve[310.7936, 61.98325, 261.8854, 53.60412, 252.0, 52.62712]; Curve[238.5165, 51.29451, 155.6176, 53.91593, 152.55, 65.99998]; Curve[146.1258, 91.30679, 146.1964, 75.57425, 114.0, 83.08163]; Curve[101.5249, 85.9905, 85.49357, 98.83845, 93.0, 114.0]; Curve[96.9852, 122.0493, 101.4202, 118.0211, 96.0, 128.775]; Curve[92.91811, 134.8897, 92.05819, 140.964, 90.00001, 147.577]; Curve[85.48869, 162.0718, 88.40478, 162.2188, 86.83928, 168.0]; Curve[84.31547, 177.3202, 68.65387, 174.0181, 70.27779, 186.0]; Curve[71.84946, 197.5966, 93.93316, 251.462, 87.75, 258.0]; Curve[83.8855, 262.0863, 74.20536, 262.4716, 73.98215, 270.0]; Curve[73.80345, 276.027, 80.97349, 281.9097, 79.26, 288.0]; Curve[76.91487, 296.3353, 44.77308, 305.2533, 60.08572, 324.0]; Curve[64.14451, 328.969, 78.96831, 335.1704, 67.77274, 342.0]; Curve[60.79922, 346.254, -5.558746, 358.62, 30.00002, 372.3488]; Curve[45.19923, 378.2171, 84.23178, 361.5336, 114.0, 376.1087]; Curve[140.1327, 388.9037, 163.6664, 405.2124, 192.0, 413.3529]; }; pa: ImagerBasic.PixelArray _ NEW[ImagerBasic.PixelArrayRep _ [ xPixels: 20, yPixels: 18, maxSampleValue: 1, samplesPerPixel: 1, m: ImagerTransform.Scale[1], get: PAGet, data: NIL ]]; checks: ImagerBasic.SampledColor _ NEW[ImagerBasic.ColorRep.sampled _ [sampled[ transparent: FALSE, pa: pa, m: ImagerTransform.Scale[2], colorOperator: $SampledBlack ]]]; PAGet: PROC [ self: ImagerBasic.PixelArray, buffer: ImagerBasic.PixelBuffer, nSamples: NAT, layer: INT, xStart, yStart: Scaled.Value, xDelta, yDelta: Scaled.Value ] ~ { FOR i: NAT IN [0..nSamples) DO WHILE xStart.Floor < 0 DO xStart _ xStart.PLUS[Scaled.FromInt[self.xPixels]] ENDLOOP; WHILE yStart.Floor < 0 DO yStart _ yStart.PLUS[Scaled.FromInt[self.yPixels]] ENDLOOP; WHILE xStart.Floor >= self.xPixels DO xStart _ xStart.MINUS[Scaled.FromInt[self.xPixels]] ENDLOOP; WHILE yStart.Floor >= self.yPixels DO yStart _ yStart.MINUS[Scaled.FromInt[self.yPixels]] ENDLOOP; buffer[i] _ Basics.BITAND[1, Basics.BITXOR[xStart.Floor, yStart.Floor]]; xStart _ xStart.PLUS[xDelta]; yStart _ yStart.PLUS[yDelta]; ENDLOOP; }; RotMerc: PROC [context: Context, data: REF _ NIL] = { gray: Imager.Color _ Imager.MakeGray[0.5]; {do: PROC = { context.ScaleT[3.527777e-4]; context.TranslateT[4.25*72, 5.5*72]; context.ScaleT[0.333]; {action: PROC = { context.SetColor[Imager.black]; context.MaskFill[mercuryPath]; FOR i: NAT _ 0, i+2 WHILE i<9 DO context.SetColor[gray]; context.RotateT[-20]; context.MaskFill[mercuryPath]; context.SetColor[Imager.black]; context.RotateT[-20]; context.MaskFill[mercuryPath]; ENDLOOP; }; context.DoSave[action]}; {action: PROC = { FOR i: NAT IN [0..2) DO context.ExcludeOutline[mercuryPath]; context.RotateT[-20]; ENDLOOP; context.RotateT[-160]; FOR i: NAT _ 10, i+2 WHILE i<18 DO context.SetColor[gray]; context.RotateT[-20]; context.MaskFill[mercuryPath]; context.SetColor[Imager.black]; context.RotateT[-20]; context.MaskFill[mercuryPath]; ENDLOOP; }; context.DoSave[action]}; }; context.DoSave[do]}; }; PageCorners: PROC [context: Context, data: REF _ NIL] = { bounds: Imager.IntRectangle; arrowHead: Imager.Trajectory; theta: REAL; bounds _ Imager.GetView[context]; theta _ RealFns.ArcTanDeg[bounds.h, bounds.w]; arrowHead _ Imager.MoveTo[[0,0]].CurveTo[[0,.5],[0,.6],[.5,1]].LineTo[[0, .75]].LineTo[[-.5,1]].CurveTo[[0,.6],[0,.5],[0,0]]; {do: PROC = { context.ScaleT[3.527777e-4]; {action: PROC = { context.RotateT[theta-90]; context.ScaleT[80]; context.MaskFill[arrowHead]; }; context.DoSave[action]}; {action: PROC = { context.TranslateT[bounds.w, 0]; context.RotateT[90-theta]; context.ScaleT[80]; context.MaskFill[arrowHead]; }; context.DoSave[action]}; {action: PROC = { context.TranslateT[0, bounds.h]; context.RotateT[-90-theta]; context.ScaleT[80]; context.MaskFill[arrowHead]; }; context.DoSave[action]}; {action: PROC = { context.TranslateT[bounds.w, bounds.h]; context.RotateT[90+theta]; context.ScaleT[80]; context.MaskFill[arrowHead]; }; context.DoSave[action]}; context.MaskStroke[Imager.MoveTo[[0, 0]].LineTo[[bounds.w, bounds.h]], 2, butt]; context.MaskStroke[Imager.MoveTo[[bounds.w, 0]].LineTo[[0, bounds.h]], 2, butt]; }; context.DoSave[do]}; }; textSize: REAL _ 12.0; Times: PROC [size: REAL] RETURNS [FONT] ~ { RETURN [Font.CreateScaled["Xerox/PressFonts/TimesRoman/MRR", size, $Ideal]] }; fontName: ROPE _ "Xerox/PressFonts/TimesRoman/MRR"; MaskTxt: PROC[context: Context, data: REF] = { ropes: LIST OF REF _ NARROW[data]; row: INT _ 0; font: FONT _ Font.CreateScaled[fontName, textSize, $Ideal]; {action: PROC = { context.ScaleT[3.527777e-4]; context.TranslateT[72, 720]; FOR list: LIST OF REF _ ropes, list.rest UNTIL list=NIL DO row _ row + 1; context.SetXY[[0, -row * textSize]]; context.ShowCharacters[list.first, font]; ENDLOOP; }; context.DoSave[action]}; }; MaskText: PROC[context: Context, data: REF] = { ropes: LIST OF REF _ NARROW[data]; curfont: FONT _ Font.CreateScaled["Xerox/PressFonts/TimesRoman/MRR", textSize, $Ideal]; altfont: FONT _ Font.CreateScaled["Xerox/PressFonts/Helvetica/MRR", textSize, $Ideal]; row: INT _ 0; {action: PROC = { context.ScaleT[3.527777e-4]; context.TranslateT[72, 720]; FOR list: LIST OF REF _ ropes, list.rest UNTIL list=NIL DO tempfont: FONT ~ curfont; row _ row + 1; context.SetXY[[0, -row * textSize]]; context.ShowCharacters[list.first, tempfont]; curfont _ altfont; altfont _ tempfont; ENDLOOP; }; context.DoSave[action]}; }; justifiedMeasure: REAL _ 0; MaskJustifiedText: PROC[context: Context, data: REF] = { ropes: LIST OF REF _ NARROW[data]; curfont: FONT _ Font.CreateScaled["Xerox/PressFonts/TimesRoman/MRR", textSize, $Ideal]; altfont: FONT _ Font.CreateScaled["Xerox/PressFonts/Helvetica/MRR", textSize, $Ideal]; row: INT _ 0; maxWidth: REAL _ 0; nWidths: INT _ 0; totalWidths: REAL _ 0; FOR list: LIST OF REF _ ropes, list.rest UNTIL list=NIL OR list.rest = NIL DO tempfont: FONT ~ curfont; width: REAL ~ tempfont.TextWidth[list.first]; maxWidth _ MAX[maxWidth, width]; nWidths _ nWidths + 1; totalWidths _ totalWidths + width; curfont _ altfont; altfont _ tempfont; ENDLOOP; curfont _ Font.CreateScaled["Xerox/PressFonts/TimesRoman/MRR", textSize, $Ideal]; altfont _ Font.CreateScaled["Xerox/PressFonts/Helvetica/MRR", textSize, $Ideal]; {action: PROC = { context.ScaleT[3.527777e-4]; context.TranslateT[72, 720]; IF nWidths > 0 THEN context.SetCorrectMeasure[[justifiedMeasure _ (maxWidth+totalWidths/nWidths)/2.0, 0]]; FOR list: LIST OF REF _ ropes, list.rest UNTIL list=NIL DO tempfont: FONT ~ curfont; Show: PROC ~ {context.ShowCharacters[list.first, tempfont]}; row _ row + 1; context.SetXY[[0, -row * textSize]]; IF list.rest = NIL THEN Show[] ELSE context.Correct[Show]; curfont _ altfont; altfont _ tempfont; ENDLOOP; }; context.DoSave[action]}; }; Text: PROC RETURNS [ropes: LIST OF REF] = { new: LIST OF REF _ NIL; txt: LIST OF ROPE _ text; WHILE txt # NIL DO new _ CONS[txt.first, new]; txt _ txt.rest ENDLOOP; WHILE new # NIL DO tt: LIST OF REF _ new; new _ new.rest; tt.rest _ ropes; ropes _ tt ENDLOOP; }; text: LIST OF ROPE _ LIST["In olden times when wishing still", "helped one, there lived a king", "whose daughters were all", "beautiful, but the youngest was", "so beautiful that the sun itself,", "which has seen so much, was", "astonished whenever it shone in", "her face. Close by the king's", "castle lay a great dark forest,", "and under an old lime-tree in", "the forest was a well, and when", "the day was very warm, the", "king's child went out into the", "forest and sat down by the side", "of the cool fountain, and when", "she was bored she took a golden", "ball, and threw it up on high", "and caught it, and this ball was", "her favorite plaything."]; END. ImagerTester.mesa Michael Plass, January 17, 1984 10:52 am object implementation fills this with the requested number of samples. number of samples to put in buffer. in the range [0..samplesPerPixel) position of first sample. increment to get to successive samples. Ê ¸˜Jšœ™J™(šÏk ˜ J˜J˜J˜ J˜J˜J˜J˜J˜—šœœ˜Jšœ7˜>—Jšœ˜Jšœœ˜Jšœ œ˜Jšœœ œ˜Jšœœœ˜Jšœ œ*˜:šÏn œœ!œ˜TJšœ2˜2šÐknœœ œ ˜#Jšœ5˜;Jšœ˜—Jšžœœœ5˜SJšœ'˜'Jšœ>˜>Jšœ?˜?JšœB˜BJšœB˜BJšœ:˜:JšœB˜BJšœ?˜?Jšœ?˜?Jšœ>˜>Jšœ>˜>Jšœ@˜@Jšœ?˜?Jšœ>˜>Jšœ?˜?Jšœ?˜?Jšœ?˜?Jšœ?˜?Jšœ?˜?Jšœ?˜?Jšœ<˜˜>Jšœ;˜;Jšœ?˜?Jšœ>˜>Jšœ@˜@Jšœ?˜?Jšœ?˜?Jšœ˜—šœœ˜>Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ ˜ Jšœ˜ Jšœ˜—šœ#œ)˜OJšœ œ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šœœ˜ Jšœ˜šœ ˜ JšœF™F—šœ œ˜J™#—šœœ˜ Jšœ!™!—šœ˜J™—šœ˜J™'—Jšœ˜šœœœ˜Jšœœœœ˜UJšœœœœ˜UJšœœœœ˜bJšœœœœ˜bJšœœ œ˜HJšœœ ˜Jšœœ ˜Jš˜—Jšœ˜—šžœœœœ˜5J˜*šœœ˜ Jšœ˜J˜$J˜šœ œ˜Jšœ˜Jšœ˜šœœ œ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜—Jšœ˜—šœ œ˜šœœœ˜Jšœ$˜$Jšœ˜Jš˜—Jšœ˜šœœ œ˜"Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jš˜—Jšœ˜—Jšœ˜—Jšœ˜—šž œœœœ˜9J˜J˜Jšœœ˜ Jšœ!˜!Jšœ.˜.J˜}šœœ˜ Jšœ˜šœ œ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šœ œ˜Jšœ ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šœ œ˜Jšœ ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šœ œ˜Jšœ'˜'Jšœ˜Jšœ˜Jšœ˜Jšœ˜—JšœP˜PJšœP˜PJšœ˜—Jšœ˜—Jšœ œ˜š žœœœœœ˜+Jšœ1œ˜KJšœ˜—Jšœ œ%˜3šžœœœ˜.Jš œœœœœ˜"Jšœœ˜ Jšœœ1˜;šœ œ˜Jšœ˜Jšœ˜š œœœœœœ˜:Jšœ˜Jšœ$˜$Jšœ)˜)Jš˜—Jšœ˜—Jšœ˜—šžœœœ˜/Jš œœœœœ˜"Jšœ œ2œ˜WJšœ œ1œ˜VJšœœ˜ šœ œ˜Jšœ˜Jšœ˜š œœœœœœ˜:Jšœ œ ˜Jšœ˜Jšœ$˜$Jšœ-˜-Jšœ&˜&Jš˜—Jšœ˜—Jšœ˜—Jšœœ˜šžœœœ˜8Jš œœœœœ˜"Jšœ œ2œ˜WJšœ œ1œ˜VJšœœ˜ Jšœ œ˜Jšœ œ˜Jšœ œ˜šœœœœœœœ œ˜MJšœ œ ˜Jšœœ"˜-Jšœ œ˜ Jšœ˜Jšœ"˜"Jšœ&˜&Jš˜—Jšœ9œ˜QJšœ8œ˜Pšœ œ˜Jšœ˜Jšœ˜Jšœ œW˜jš œœœœœœ˜:Jšœ œ ˜Jšžœœ2˜