beta-0.89.2
[luatex.git] / source / texk / web2c / triptrap / trap.mp
blob1be226401f78a61a7842f9512771302a7cbff19a
1 % This is a test file for MetaPost analogous to trap.mf
2 if not known inimp: .inimp.=.0. % next lines are skipped if format loaded
3   inimp; nonstopmode; tracingtitles:=day; showstopping:=year;
4   << == >> ::: || `` '' -- !! ?? ## && @@ $$ [[ ]] {{ }} . (( 5.5.5 )) ++ "..";
5   begingroup save =; let=,; save,; newinternal $=,; let ):=, endgroup;
6   let year=month; showvariable errorstopmode,readstring,2,"2",,,(,),<<,year;
7   tracingrestores:=tracingcommands:=.00000762939453125; % that's 2^(-17)
8   if tracingcommands>0:tracingcommands:=if not cycle "":1.1 forever;fi;
9   tracingcommands:=2.1 exitif tracingcommands>2 endfor; showtoken |=:|>;
10   tracinglostchars:=1/.00001; tracingequations:=$+1; p~=tracinglostchars+.00001;
11   interim tracingspecs:=tracingchoices:=tracingstats:=
12   warningcheck:=tracingoutput:=tracingmacros:=1; $:=ASCII""; $:=x; p~:=p~;
13   delimiters (); delimiters begintext endtext; vardef foo(text t)=t enddef;
14   def lig(text t,|)=ligtable0::for *=1step1until60:0kern boundarychar+*,endfor
15   skipto0;ligtable t:t|0,skipto255;boundarychar:=boundarychar+51.29999enddef;
16   foo begintext interim tracinglostchars:=(.5;show urcorner("flubo"infont"trapf"
17   ),2+2endtext; for n=tracingspecs step 1 until $:fi endfor showstats;
18   let!!=skipto; path p~; p~=(0,0)..controls (15,4) and (-15,-12)..(4,0);
19   everyjob /*\;; vardef /*\`'@#=message @ & str#@ &jobname&char ASCII'`&str@#!
20   enddef;let next=endinput;vardef `'='` enddef;def '`="\*/"enddef;
21   begingroup errorstopmode; endgroup;
22 elseif known"": `'pass[2.]; nonstopmode; outer\; let next=\; delimiters ^~7! fi
23 next\; % the second pass will now compute silently; the first pass will halt
24 batchmode; ^~7,endgroup pausing:=1; exitif p exitif boolean pen pencircle endfor
25 scantokens begingroup message char0&"watch this"; "pair p[],';"&char-1endgroup
26 path p[][]p,w,qw; qw=(1,-2)..(2,-1)..(2.5,0.5)..(1,2)..(turningnumber',2.5);
27 numeric p[][]; p[[ [$] ]]=10000000000000000; "this string constant is incomplete
28 string foo[]p,p~if true:[];
29 boolean p[]~,boolean fi.boolean; showvariable boolean;
30 inner \; def\\= =show enddef; outer \;  picture e[]e[], e[], p~[]~[][];
31 pen p~[]~,q["a",qq; p~1~=q=pencircle scaled mexp(-3016.57654);
32 transform p,pp0; if p=p:qq=makepen((7,0)..cycle) xscaled hex "1000";show qq;fi
33 qq:=makepen((4,1)..(1,2)..(5,3)..(3,2)..(1,1)..(0,1)..(1,0)..cycle);show qq;
34 vardef p[][]p~ begintext suffix a,b endtext())suffix@=show #@; p.a.b() enddef;
35 expandafter let\endtext\\; outer endtext,\,;;
36 (6,12)-p7=(0,1)transformed p=(2/(x-x),3/0)transformed p;
37 p1\2p=p007=begintext if string p~[$]: p.1.2-p.1.199999,1 endtext transformed p;
38 showstopping:=0;showvariable p; p=p; let [[=begingroup; let ]]=endgroup;
39 (xxpart p+.002,yxpart p)=1[p1,p2]=(5,y+.00001)=(5,y)=(yypart p,xypart p);
40 reverse(p~..cycle) transformed p=p2. 3.p;
41 p[000000000001]2p~(,[2]3p~,-)=p~1~2[pausing];
42 vardef p~[]@# tertiary t:=if p@ @=@ @p fi; vardef p[][]p~[]=BAD; inner ;;
43 show p~[-2]~[3000,x]++4000>path p3; showvariable p,P;
44 numeric p[]~; p3~=2alpha; p[1/$]~=3beta;
45 begingroup save p; showvariable p; 3beta=1]]; showvariable p;
46 def//expr;=enddef;def!primary!false):!fi enddef;
47 def _aa__ secondary _a_=if(true enddef; qq:=makepen(qw..(qw scaled$)..cycle);
48 show qq; primarydef _**__=[[show _*__]] enddef;
49 secondarydef _***__=expandafter __ scantokens"**oct"_ enddef;
50 // //pencircle slanted length p~**makepen reverse subpath p7-p2 of
51  (p7{p2}..controls _aa__ not odd.1(15) and known p or !p2and-p2..{1,1}(-p2
52  {curl- +1)..tension atleast1..cycle sqrt2++sqrt2***[[]];
53 charcode:=-20.5;chardp:=-2048;shipout nullpicture;
54 if charexists -275.50002>known p0 0p=known p~: randomseed charcode; fi
55 randomseed:="goof"; a[($,18++1+-+18),(2,3)]=b[(3,2),(1,$);
56 show (^+1,~+2) slanted-1 yscaled-2 zscaled-(3,4), p transformed(pp xscaled 9),
57  pp shifted (1,2) transformed(p transformed p), -_[0][1,2]; show
58 floor sind mlog sqrt mexp200cosd angle(normaldeviate,uniformdeviate-chardp);
59 string s[]; s1=s2=s4; s3=s5; s1=s2; if s1<=s4<>(s1<>s3):show[[char34=s2:=s3]]fi;
60 substring penoffset point.1of.p~of[[pencircle]]rotated1080/2/1/3of decimal
61  directiontime postcontrol-1.5of(p~&cycle)-precontrol1/2of p~(p~)=s1:=s4:=s4;
62 path p~[]; p~1=p2{length"  "}&cycle; p~1=p2=p~0; p2..controls-p2..cycle=p~2;(p7
63 ..tension1.2..p~[length p~2]..p~2&{0,1}p2..tension1and atleast1..cycle)..tension
64  x..{curl1}-p7{curl hex "IsBad"}..tension.75and.74999..p2{0,1}&p2{_,'}..cycle:=p
65  ~4; subpath(-9,9)of subpath(3.5001,7.00001)of p~4=p~6;
66 show p~6, directiontime(1,2) of p~6, directiontime(1,-1.00001) of p~6;
67 p~3=(0,0)..controls (1,1) and (0,1)..(1,0); show p2..p2{p7}&{$,$}cycle,
68  (directiontime(1,1) of subpath(.314159,1) of p~3)[.314159,1];
69 p~5=(subpath(0,.25)of p~3&subpath(.25,1)of p~3)shifted begintext1,0;
70 p~3:=2/3'zscaled'{p~3}..controls(2,2/3(3))and penoffset(1/2x,y)of(0,1)(1,0);
71 show p~3 intersectiontimes reverse p~3, point.17227 of p~3, point1-.28339of p~3;
72 show point xpart(p~5 intersectiontimes p~5 shifted (.01,0))of p~5-
73  point ypart(p~5 intersectiontimes p~5 shifted (.01,0))of p~5;
74 [[ e[-1+-+ -1.00001]=nullpicture; addto e1 also[[
75 addto e0 doublepath p~5 scaled 3 withpen q; e0=e1=e2;
76 nullpicture]];show e1, e2 shifted (-3,0) ]];
77 addto e1 also  e2 shifted(-2,$); e1:=e1 shifted(-4,$);
78 addto e1 doublepath (0,9) withcolor(.4,turningnumber p~4,0)
79  withpen qq xscaled(oct"180"++1) rotated-angle(64,$) shifted (9,8);
80 show e1; chardp:=charcode:=5; xoffset:=-1.5; shipout e1; e3=nullpicture;
81 showstats; addto e3doublepath(.5,0)..(3.5,1.5)dashed e0;
82  q:=makepen((1,1)..cycle) yscaled 1.5;
83 chardx:=chardp:=charext:=-14.5;charcode:=6;shipout e2;
84 p~9=(0,0)..(1,.5)..(5,1.5)..(7,2.5)..(12,3.5)..(13,4);addto e3 doublepath p~9;
85 addto doublepath (-4095,0)..tension
86 3/4 and 999..(0,2); show e3 rotated-90;
87 if "a" if "ab">"b" elseif path reverse (3,4): >="aa":foo elseif fi "bar"
88 else if '-(1,yy)<': :fi else def dup text t=[[t;save enddef;def|suffix$=,$
89 enddef; def||tertiary p=show substring p of("a" enddef;||(2,$)&"bc");
90 tertiarydef x++y=[[dup showtoken x;]];def quote x expr z of y=z enddef;
91  texts(quote x=(y+0)y+y)("xx",foo(x))=0]] enddef; def texts(text t,tt)expr?=
92  for n:=,for n"yy":n,length if false:endfor tt,t,:if string n:forsuffixes n=
93  foo1,[foo(n)],':show t,tt|(n;exitif not('<='+(?,yy)) endfor for m= :+endfor
94   for m=alpha step-1.1 3$: +m endfor fi endfor enddef; show (0,0){curl2}..
95  subpath(23.3,4.5)of p~9{curl3}..($,$){curl4}..cycle;zzz=p~++2+3;[[
96 let?=if;save if,\;def if=endinput?enddef;def texts=input enddef;texts trap ]];
97 dup[[def texts secondary x=primarydef y++y=x@y enddef; showtoken++;x enddef]]\;
98 texts:="a"&"b";% strings "yy" and "ab" no longer appear in memory
99 texts-1.00001a1=-(a2+a3+a4+a5+a6);-(a3,a2)/.99999=-(a4+a5+[[showdependencies;
100 a6]],a3+a4+a5+a6)]]; 1.00001a4+1=a5+a6; alpha:=.9alpha+7; showdependencies;
101 a5=a6=2/3-a6; charcode:=chardp:=27; 3.1=aaz; show aaz; ligtable||:255|=:|>>0,
102 skipto0; show [[interim tracingcommands:=0; lig("g")(=:|); lig("h":"i")(|=:);
103 lig("j")(|=:>);lig("k")(=:|>); lig("l")(|=:|>)]];
104 b1:=c.a[ [[let c=++;vardef b=enddef;1]] ]; ligtable"m":0=:0,skipto5;
105 !!; errhelp 0; errmessage "Be like Jane";
106 errhelp "He%%%lp%"; errmessage""; errhelp ""; errmessage "Another";
107 headerbyte 0; headerbyte(48.5)substring(-9,9)of"long"; for\=0:\
108 headerbyte 9:2a6,"q"; fontdimen 9:2a6,"q"; fontdimen 1:2048;
109 fontmaking:=1; extensible 5 5,"c"255.5,"d"; charlist 0:5:"a":"d";
110 ligtable255:255::"a"=:"b","d" kern -2048,"c":0:99.5:"e"|=:|"f",0kern';
111 ligtable 5:0; def clear(text x)=interim x:=$ enddef; clear(hppp); vppp=0;
112 [[clear(tracingmacros); clear(tracingcommands); clear(tracingoutput\;
113  designsize:=.99999;charcode:=ASCII char-418.5;
114  def dp expr d = charcode:=charcode+1; chardp:=d; shipout nullpicture enddef;
115  dp 13; dp 12; dp 0; dp 21; dp -2; dp 17; dp 11; dp 3; charic:=-1000; dp -1;
116  dp 25; dp 31; dp 19; dp 7; charwd:=256; chardy:=6; dp 23; dp 30]];
117 def f(suffix@@)(expr a,b)(text t)=numeric w; show a; % wipes out the old w
118 addto @@ contour (0,0)..(2,0)..(1,$)..(1,1)..cycle withpen qq; % strange path
119 addto @@ doublepath (0,0){1,1}..{2,1}(2,1) withpen qq; % carefully chosen
120 addto @@ doublepath(($,$){1,0}..(1,1){1,0})scaled.5 withpen nullpen;
121 enddef; def g(suffix$)=show $ enddef;
122 addto e0 contour (0,0){1,0}..{1,0}(1,0){0,$}..{0,1}cycle withpen qq;
123 f(e[3,w); g(e3,transformed p,penoffset-(1,1.3)of(pencircle scaled20 yscaled-.5),
124  directiontime (0,1) of ((0,0)..controls(1,1)and($,1)..(3,0)),
125  point 3.14159 of p~9 intersectiontimes subpath (3.14159,4) of p~9,
126  (($,1.1)..(1,$)) intersectiontimes precontrol$ of (0,0);
127 addto e3 doublepath(-4094.99998,0)..(4094.99998,-.00001) withpen penoffset 0 of
128 pencircle; addto e3 also e3 shifted (0,257); ,"flushed with pride"; numeric xx;
129 def f(expr x,y,z)=showdependencies;tracingcapsules:=1;showdependencies;show
130  1/3(3,6)*((x+y)+(y-x)), (1,1)/sqrt2 zscaled (x+1,x+2) - (x+1,x+2) rotated 45,
131  (0,1) zscaled (1,y+2)-(1,y+2) rotated 90 enddef; f((xx+1)/.3,(yy-1)/.5,(xx,0));
132 '=(1000o3-4000(o1-o2)+4000o2+9,-.01o3+3ooo+
133  [[oo=9/10(o2+o4+o5-20);o4=o5=8/9(o1+.5o2); o6=-.0001o2;showdependencies;
134   numeric o[];xpart(alfa,[[pair alfa;0]])]])=-2/3[[save p;(p$,1-p$)]];
135 xoffset:=yoffset:=4000[[oo=.5ooo=2*-1/2(ooo+[[numeric ooo;1]]);oo]];
136 addto foo contour begingroup vardef foo=enddef; (0,0)..cycle endgroup;
137 p~7=p~8; p~8:=(0,0){-1,1}..(30,0); show p~8, directiontime (0,-1)of p~8;
138 show directiontime (1,0) of p~9, directiontime(1,-1)
139 of ((0,0){1,0}..(0,0){0,-1)..cycle);
140 e9=e4=nullpicture; addto e4 doublepath p~8;
141 addto e9 doublepath p~8 dashed e4; e9:=nullpicture;
142 e4:=nullpicture; addto e4 doublepath(1,1)..(4,1);
143 addto e9 doublepath p~8 dashed e4; e9:=nullpicture;
144 addto e4 doublepath makepath pencircle dashed e4 scaled -2; show e4;
145 e4:=e5=nullpicture; addto e4 doublepath (-4,-3)..tension 2..(-2,-2.7);
146 addto e5 doublepath p~5 shifted (0,4) scaled 3 dashed e4 withpen qq;
147 show llcorner e5;  verbatimtex \font\tra=trapf at 10pt
148     \font\trb=trapf at 20pt % TeX comment only!" etex
149 e6:=nullpicture; addto e6 doublepath (0,0)..(30,0) dashed makepath pencircle
150 dashed e5 withpen pencircle scaled2 dashed e5shifted(0,-11)
151 withpen pencircle; show e6; def -- = {curl1}..{curl1}enddef;
152 p~7 := p~8 rotated 90 xscaled -1 .. cycle; linecap:=2; linejoin:=1;
153 e6=nullpicture; addto e6 doublepath p~8 dashed e5 withpen pencircle;
154 clip e6 to p~7; addto e6 also btex \tra Aqua \vrule\trb Brass etex
155  shifted(0,-2); addto e6 doublepath (1,0)..(2,1); addto e5 also
156  e6 withcolor .5*(1,1,1) dashed e4 withpen pencircle xscaled 2 rotated 45;
157 addto e5 also btex \tra mast etex shifted(0,10);
158 show e6, lrcorner e5, ulcorner e5; charcode:=200; shipout e5;
159 showstats; e5:=e6:="curb"infont"trapf" slanted-.5 scaled-1; showstats;
160 show penoffset(0,0)of pencircle, llcorner e5, urcorner e5;
161 e5:=e5 rotated 90 shifted "oops"; show llcorner e5, urcorner e5;
162 show urcorner (char220 infont "trapf"), makepath qq;
163 show subpath(-2,-1)of p~8, subpath(9,10)of makepath pencircle;
164 "hi" infont "qw99z"; special "ij"="ij"; show substring(-2,-1)of"abc";
165 addto e5 contour [[ ]]; addto e5 contour true; pausing:=0;prologues:=1;
166 charcode:=197; shipout e5; p~10=(0,0){1,1.01}..tension atleast 1..{1,0}
167 (1,1){-1,1}..(2,0){1,-1}; prologues:=0; for d=(-1,1),(1,-1),(0,0):
168 show directiontime d of p~10; endfor  linejoin:=linecap:=1;
169 e5:=nullpicture; addto e5 contour makepath(pencircle scaled 10)
170 withpen pencircle shifted(2,0);  addto e5 doublepath (0,0)..(12,0)
171 withpen pencircle yscaled 3; charcode:=148; shipout e5;
172 e5:=nullpicture; clip p~8 to; clip e5 to e4; clip e5 to p~8; clip e5 to p~7;
173 addto e5 doublepath makepath(pencircle scaled 50) withpen qq;
174 addto e5 doublepath p~8 withpen pencircle  xscaled 2 dashed e4;
175 addto e5 doublepath p~8 withpen pencircle dashed e4;
176 addto e5 doublepath p~8 shifted (10,0) dashed e4 scaled 1 withpen pencircle;
177 charcode:=149; shipout e5;  addto 3; addto p~8 contour p~7;
178 e5:=nullpicture; linecap:=2; linejoin:=0; miterlimit:=10;
179 addto e5 contour (10,5)..cycle withpen qq;
180 addto e5 doublepath (5,10)..(5,15) withpen qq;
181 addto e5 doublepath (0,0)..controls(10,10)..(10,10)..(0,20){curl1}..(30,10)
182 withpen makepen((0,-5)..(0,5)..cycle); charcode:=150; prologues:=1; shipout e5;
183 for @=angle(sqrt$,mlog$):charext:=uniformdeviate$;charht:=2048;
184 addto e3 contour (0,-100)..tension 500..(100,-99)..tension 3000..cycle;
185 tracingoutput:=@; special "bye"; charcode:=151; shipout e3;
186 interim char 99 = "c"; true=false; show penoffset (2,1) of qq;
187 showstats; let f=faz; showtoken f; showstats;
188 e17=nullpicture; addto e17 doublepath (-4,-5)..(6,5);
189 setbounds e17 to makepath(pencircle scaled 9); show llcorner e17, urcorner e17;
190 addto e5 also e17 shifted (-5,-5); show llcorner e5; truecorners:=2;
191 show llcorner e5; truecorners:=-1;
192 setbounds e17 to makepath(pencircle xscaled 19);
193 addto e5 also e17 shifted(-5,-10); show llcorner e5, e5, urcorner pencircle;
194 e5:=nullpicture; path ap[];
195 ap1=makepath(pencircle scaled 100);
196 ap2=(2,-14)..controls (14,-7) and (14,7)..(2,14);
197 ap3=(-50,0)..controls (-50,0) .. (50,0);
198 show arclength (ap2 scaled 1000), arclength(ap3 scaled 200);
199 show arclength ap1, arclength ap2;
200 show arctime 6.4 of  ap3, arclength subpath(0,arctime 37 of ap3) of ap3;
201 show arctime -1000 of ap1, arctime -3 of ap2, arctime314 of (ap1 scaled .00001);
202 [[clear(tracingcommands); charcode:=ASCII char 269-13; shipout nullpicture;
203 "careful" quote for for = @ step 200 until 2*2600: &" METAFONT" endfor;]];
204 scrollmode; "hello again"&char31; save p;
205 def f expr x=let )=]; let [=(; show _ enddef; begingroup tracingonline:=1;
206 tracingonline:=1; f xx[1); showdependencies; qq:=q; showstats; bye endtext
207 % things not tested:
208 % interaction (error insertion/deletion, interrupts, \pausing, files not there)
209 % date, time; initialization of random number generator without randomseed
210 % system-dependent parsing of file names, areas, extensions
211 % certain error messages, especially fatal ones
212 % things that can't happen in INIMP
213 % unusual cases of fixed-point arithmetic
214 % certain other unusual cases, especially when something similar is tested
215 % most events that trigger string pool compaction
216 % features that have entered the language after 0.632