DIRECTORY PDGraphics, PressFontReader, IPImagerBasic, IPScan, PDFileWriter, RealFns, Rope ; PDGraphicsTest: CEDAR PROGRAM IMPORTS PDGraphics, PDFileWriter, PressFontReader = BEGIN Context: TYPE = PDGraphics.Context; Transform: TYPE = PDGraphics.Transform; MercuryPath: PROC [context: Context] = { context.MoveTo[192.0, 413.353]; context.CurveTo[237.5415, 425.809, 255.3458, 401.7666, 288.0, 399.5085]; context.CurveTo[297.9937, 398.8174, 308.0844, 403.6591, 318.0, 404.5501]; context.CurveTo[331.9086, 405.7998, 448.1434, 401.3464, 450.8684, 396.0001]; context.CurveTo[453.3393, 391.1521, 435.2951, 383.4805, 431.9999, 383.0218]; context.CurveTo[428.5259, 382.538, 410.233, 382.6307, 409.5, 378.0]; context.CurveTo[409.8045, 379.9238, 421.3876, 370.5168, 402.0001, 363.6874]; context.CurveTo[386.3301, 358.1678, 345.4535, 362.3779, 345.5, 359.9999]; context.CurveTo[345.4942, 360.2959, 368.3762, 359.2238, 372.0, 358.0435]; context.CurveTo[389.1935, 352.4433, 364.4147, 343.7253, 364.875, 336.0]; context.CurveTo[365.5193, 325.1856, 382.3762, 294.0994, 390.0, 285.675]; context.CurveTo[408.286, 265.4687, 417.344, 272.0564, 438.0001, 263.8696]; context.CurveTo[454.6547, 257.2686, 417.2523, 242.3468, 408.0, 243.5193]; context.CurveTo[383.1711, 246.6655, 383.3985, 232.3274, 366.0, 219.439]; context.CurveTo[352.0869, 209.1325, 366.6143, 208.1149, 372.0, 208.9024]; context.CurveTo[374.2727, 209.2348, 386.2989, 214.7218, 380.8284, 204.0]; context.CurveTo[378.6221, 199.6753, 364.5704, 185.5353, 360.0, 184.8125]; context.CurveTo[351.8828, 183.5287, 332.7219, 196.0891, 329.1539, 192.0]; context.CurveTo[321.1773, 182.8585, 343.6019, 183.1676, 340.0227, 174.0]; context.CurveTo[335.0409, 161.2398, 311.5035, 158.2857, 310.4737, 126.0]; context.CurveTo[310.1649, 116.3195, 313.5754, 76.22575, 312.75, 72.0]; context.CurveTo[310.7936, 61.98325, 261.8854, 53.60412, 252.0, 52.62712]; context.CurveTo[238.5165, 51.29451, 155.6176, 53.91593, 152.55, 65.99998]; context.CurveTo[146.1258, 91.30679, 146.1964, 75.57425, 114.0, 83.08163]; context.CurveTo[101.5249, 85.9905, 85.49357, 98.83845, 93.0, 114.0]; context.CurveTo[96.9852, 122.0493, 101.4202, 118.0211, 96.0, 128.775]; context.CurveTo[92.91811, 134.8897, 92.05819, 140.964, 90.00001, 147.577]; context.CurveTo[85.48869, 162.0718, 88.40478, 162.2188, 86.83928, 168.0]; context.CurveTo[84.31547, 177.3202, 68.65387, 174.0181, 70.27779, 186.0]; context.CurveTo[71.84946, 197.5966, 93.93316, 251.462, 87.75, 258.0]; context.CurveTo[83.8855, 262.0863, 74.20536, 262.4716, 73.98215, 270.0]; context.CurveTo[73.80345, 276.027, 80.97349, 281.9097, 79.26, 288.0]; context.CurveTo[76.91487, 296.3353, 44.77308, 305.2533, 60.08572, 324.0]; context.CurveTo[64.14451, 328.969, 78.96831, 335.1704, 67.77274, 342.0]; context.CurveTo[60.79922, 346.254, -5.558746, 358.62, 30.00002, 372.3488]; context.CurveTo[45.19923, 378.2171, 84.23178, 361.5336, 114.0, 376.1087]; context.CurveTo[140.1327, 388.9037, 163.6664, 405.2124, 192.0, 413.3529]; }; ColorBoxes: PROC [context: Context] = { Square: PROC = {context.MoveTo[0,0]; context.LineTo[0,1]; context.LineTo[1,1]; context.LineTo[1,0]; context.DrawArea}; save: PDGraphics.Transform _ context.transform; context.Scale[72]; context.Translate[[1,1]]; FOR i: NAT IN [0..6) DO context.SetColor[i/6.0,1,1]; Square[]; context.Translate[[0,1]]; ENDLOOP; context.transform _ save; context.Scale[72]; context.Translate[[2,1]]; context.SetColor[0,0,0.5]; FOR i: NAT IN [0..6) DO context.SetColor[0,0,i/6.0]; Square[]; context.Translate[[0,1]]; ENDLOOP; }; Try: PROC [proc: PROC [context: Context]] = { context: Context ~ PDGraphics.NewHornetContext["test.pd"]; proc[context]; context.pdState.EndPage; context.pdState.Close }; Testc: PROC RETURNS [context: Context] = { context _ PDGraphics.NewHornetContext["test.pd"]; }; Close: PROC [context: Context] = { context.pdState.EndPage; context.pdState.Close }; DrawBB: PROC [context: Context] = { context.MoveTo[-9999, -9999]; context.LineTo[9999, -9999]; context.LineTo[9999, 9999]; context.LineTo[-9999, 9999]; context.DrawArea; }; TryPuffin: PROC [proc: PROC [context: Context]] = { context: Context ~ PDGraphics.NewPuffinContext["puffin.pd"]; proc[context]; context.pdState.EndPage; context.pdState.Close }; GrayMercs: PROC [context: Context] = { deltaX: REAL ~ 6.5*72/37.0; deltaY: REAL ~ 9*72/37.0; save: PDGraphics.Transform ~ context.transform; baseColor: REAL _ 0.5; FOR i: NAT DECREASING IN [0..37] DO color: REAL ~ i/(2*37.0) + baseColor; context.transform _ save; context.Translate[[72, 72]]; context.Translate[[deltaX*i, deltaY*i]]; context.Scale[1/10.0]; context.SetFunnyGray[color, black]; TryMerc[context]; baseColor _ 0.5-baseColor ENDLOOP; context.transform _ save; }; TryMerc: PROC [context: Context] = { MercuryPath[context]; context.DrawArea; }; RotMerc1: PROC [context: Context] = { save: PDGraphics.Transform _ context.transform; context.Translate[[4.25*72, 5.5*72]]; context.Scale[0.333]; MercuryPath[context]; context.DrawArea; FOR i:NAT IN [0..9) DO context.SetGray[0.5]; context.Rotate[-10]; MercuryPath[context]; context.DrawArea; context.SetBlack; context.Rotate[-10]; MercuryPath[context]; context.DrawArea; ENDLOOP; context.transform _ save; }; RotMerc: PROC [context: Context] = { save: PDGraphics.Transform _ context.transform; t1, t2: PDGraphics.Transform; context.Translate[[4.25*72, 5.5*72]]; context.Scale[0.333]; t1 _ context.transform; FOR i: NAT _ 0, i+2 WHILE i<9 DO context.SetColor[i/18.0, 0.9, 0.5]; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; context.SetBlack; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; ENDLOOP; t2 _ context.transform; context.transform _ t1; FOR i: NAT IN [0..2) DO context.Rotate[-20]; MercuryPath[context]; context.ClipArea[TRUE]; ENDLOOP; context.transform _ t2; FOR i: NAT _ 10, i+2 WHILE i<18 DO context.SetColor[i/18.0, 0.9, 0.5]; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; context.SetBlack; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; ENDLOOP; context.transform _ save; }; textSize: REAL _ 20; ClippedText: PROC[context: Context] = { curfont: PressFontReader.Font _ TimesRoman[]; altfont: PressFontReader.Font _ Helvetica[]; save: PDGraphics.Transform _ context.transform; context.Translate[[72, 3*72]]; MercuryPath[context]; context.ClipArea; context.Translate[[0.25*72, 6.5*72]]; context.Scale[textSize]; FOR list: LIST OF Rope.ROPE _ text, list.rest UNTIL list=NIL DO rope: Rope.ROPE ~ list.first; t1: PDGraphics.Transform ~ context.transform; tempfont: PressFontReader.Font ~ curfont; context.DrawRope[tempfont, rope]; curfont _ altfont; altfont _ tempfont; context.transform _ t1; context.Translate[[0, -1]]; ENDLOOP; context.PopClipper; context.transform _ save; }; TryText: PROC[ropes: LIST OF REF] = {context: Context _ PDGraphics.NewHornetContext["text.pd"]; curfont: PressFontReader.Font _ TimesRoman[]; altfont: PressFontReader.Font _ Helvetica[]; context.Translate[[1.25*72, 9.5*72]]; context.Scale[textSize]; FOR list: LIST OF REF _ ropes, list.rest UNTIL list=NIL DO rope: Rope.ROPE ~ NARROW[list.first]; t1: PDGraphics.Transform ~ context.transform; tempfont: PressFontReader.Font ~ curfont; context.DrawRope[tempfont, rope]; curfont _ altfont; altfont _ tempfont; context.transform _ t1; context.Translate[[0, -1]]; ENDLOOP; context.pdState.EndPage; context.pdState.Close }; darkGray: REAL _ 0.333; lightGray: REAL _ 0.667; SetText: PROC [new: LIST OF REF] = { t: LIST OF Rope.ROPE _ NIL; WHILE new # NIL DO t _ CONS[NARROW[new.first], t]; new _ new.rest ENDLOOP; text _ NIL; WHILE t # NIL DO tt: LIST OF Rope.ROPE _ t; t _ t.rest; tt.rest _ text; text _ tt ENDLOOP; }; text: LIST OF Rope.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."]; TextWithMerc: PROC [context: Context] = { save: PDGraphics.Transform _ context.transform; ropes: LIST OF Rope.ROPE _ text; curfont: PressFontReader.Font _ TimesRoman[]; altfont: PressFontReader.Font _ Helvetica[]; textTransform, t1, t2: PDGraphics.Transform; DoTextLine: PROC = { save: PDGraphics.Transform ~ context.transform; context.transform _ textTransform; IF ropes # NIL THEN { rope: Rope.ROPE ~ ropes.first; t1: PDGraphics.Transform ~ context.transform; tempfont: PressFontReader.Font ~ curfont; context.SetGray[darkGray]; context.DrawRope[tempfont, rope]; curfont _ altfont; altfont _ tempfont; context.transform _ t1; context.Translate[[0, -1]]; ropes _ ropes.rest; }; textTransform _ context.transform; context.transform _ save; }; {mercTransform: PDGraphics.Transform ~ context.transform; context.Translate[[1.25*72, 9.5*72]]; context.Scale[30]; textTransform _ context.transform; context.transform _ mercTransform; }; context.Translate[[4.25*72, 5.5*72]]; context.Scale[0.333]; t1 _ context.transform; MercuryPath[context]; context.DrawArea; FOR i:NAT IN [0..5) DO DoTextLine[]; context.SetGray[lightGray]; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; DoTextLine[]; context.SetBlack; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; ENDLOOP; t2 _ context.transform; context.transform _ t1; FOR i: NAT IN [0..3) DO context.Rotate[-20]; MercuryPath[context]; context.ClipArea[TRUE]; ENDLOOP; context.transform _ t2; FOR i:NAT IN [0..4) DO DoTextLine[]; context.SetGray[lightGray]; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; DoTextLine[]; context.SetBlack; context.Rotate[-20]; MercuryPath[context]; context.DrawArea; ENDLOOP; WHILE ropes # NIL DO DoTextLine[] ENDLOOP; context.transform _ save; }; timesRoman: PressFontReader.Font; TimesRoman: PROC RETURNS [PressFontReader.Font] = TRUSTED { IF timesRoman = NIL THEN timesRoman _ PressFontReader.FirstFont[ PressFontReader.FromFile["[Indigo]TIMESROMAN-MRR.sd"] ]; RETURN [timesRoman] }; helvetica: PressFontReader.Font; Helvetica: PROC RETURNS [PressFontReader.Font] = TRUSTED { IF helvetica = NIL THEN helvetica _ PressFontReader.FirstFont[ PressFontReader.FromFile["[Indigo]HELVETICA-MRR.sd"] ]; RETURN [helvetica] }; classic: PressFontReader.Font; Classic: PROC RETURNS [PressFontReader.Font] = TRUSTED { IF classic = NIL THEN classic _ PressFontReader.FirstFont[ PressFontReader.FromFile["[Indigo]CLASSIC-MRR.sd"] ]; RETURN [classic] }; END. >PDGraphicsTest.mesa Michael Plass, May 13, 1983 2:14 pm Ê ¢˜Jšœ™J™#šÏk ˜ J˜ J˜Jšœ˜Jšœ˜Jšœ ˜ J˜J˜J˜—šœœ˜Jšœ*˜1—Jšœ˜Jšœ œ˜#Jšœ œ˜'šÏn œœ˜(J˜J˜HJ˜IJ˜LJ˜LJ˜DJ˜LJ˜IJ˜IJ˜HJ˜HJ˜JJ˜IJ˜HJ˜IJ˜IJ˜IJ˜IJ˜IJ˜IJ˜FJ˜IJ˜JJ˜IJ˜DJ˜FJ˜JJ˜IJ˜IJ˜EJ˜HJ˜EJ˜IJ˜HJ˜JJ˜IJ˜IJšœ˜—šž œœ˜'Jšžœœj˜vJšœ/˜/Jšœ˜Jšœ˜šœœœ˜Jšœ˜Jšœ ˜ Jšœ˜Jš˜—Jšœ˜Jšœ˜Jšœ˜Jšœ˜šœœœ˜Jšœ˜Jšœ ˜ Jšœ˜Jš˜—Jšœ˜—šžœœœ˜-Jšœ:˜:Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šžœœœ˜*Jšœ1˜1J˜—šžœœ˜"Jšœ˜Jšœ˜Jšœ˜—šžœœ˜#Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜—šž œœœ˜3Jšœ<˜Jšœ@˜@J˜—Jšœ ˜Jšœ˜—Jšœ˜šžœœœœ˜8šœ œœ%˜:Jšœ>˜>J˜—Jšœ ˜Jšœ˜—Jšœ˜J˜—…—*64