Debian Codegraph @

texmf-dist/source/metafont/roex/roexsamp/ro-06.mf

raw
1 %%%%
2 %%%% This file belongs to the ROEX package.
3 %%%%
4 %%% draw write_preamble write_postamble find_BB set_BB fill_C draw_C
5 %%% draw fix_fill_cmyk fix_draw_cmyk
6 %%% draw fix_line_join fix_line_cap fix_line_width
7 % RO-06.MF, ``EL PALO ALTO TREE'':
8 % A tough example (see remarks below) excerpted from The \MF{}book, pages
9 % 124 thru 126.
10 %% % an innocent formatting trick: the underscore character ending a name
11 %% % will be typeset as an superscript asterisk
12 %% \let\oriunderscore\_
13 %% \newif\ifbgroupopen \bgroupopenfalse
14 %% \def\altdblbackslash#1{\bgroup\bgroupopentrue\it#1}
15 %% \def\optegroup{\ifbgroupopen\egroup\fi}
16 %% \def\underscoreasasterisk#1{%
17 %% \ifx#1\relax\optegroup^*\else\oriunderscore#1\fi}
18 %% \def\\#1{%
19 %% \let\_\underscoreasasterisk
20 %% \altdblbackslash{#1\relax}\optegroup
21 %% \let\_\oriunderscore}
22 % ---
23 input mftoeps; eps_mode_setup; input roex; tracingremoving:=1;
24 % ---
25 % REMARKS:
26 % 1. There arise very close points during the intersecting process,
27 % hence |epsil.dist| is adjusted (see also point 2).
28 % 2. Note that:
29 % a) |turningnumber(branch1)=1| but |turningnumber(reverse branch1)=0|
30 % (sic!);
31 % b) for the second resulting path, |R2| (the tree), |turningnumber(R2)=1|
32 % while |check_turn(R2)=-1|, which is the desired value as the tree
33 % is unfilled (oh, these tiny loops!);
34 % c) the minimal resulting interval, i.e., the time distance
35 % between two neighbouring points of intersection is dangerously
36 % small, namely, |0.00032|; usually the value smaller than the bound,
37 % by default equal to |0.01|, portends a collaps of the algorithm,
38 % fortunately not in this case (set |tracingremoving:=2| for more
39 % information on intervals and secants).
40 epsil.dist:=1/50pt;
41 % show_turningnumbers_and_turn_checks:=1;
42 % mark_trunk_close_points:=1;
43 % ---
44 beginchar ("0",1/2in#,5/4in#,0);
45 path branch[\\], oval;
46 %
47 % prepare data:
48 branch0 = % i.e., trunk
49 (0,660)---(-12,70)..{curl 5}(-28,-8)
50 & flex((-28,-8),(-16,-4),(-10,-11))
51 & flex((-10,-11),(0,-5),(14,-10))
52 & flex((14,-10),(20,-6),(29,-11))
53 & (29,-11){curl 4}..(10,100)---cycle;
54 branch1= flex((0,660),(-9,633),(-22,610))
55 & flex((-22,610),(-3,622),(17,617))
56 & flex((17,617),(7,637),(0,660)) & cycle;
57 branch2=flex((30,570),(10,590),(-1,616))
58 & flex((-1,616),(-11,592),(-29,576),(-32,562))
59 & flex((-32,562),(-10,577),(30,570)) & cycle;
60 branch3=flex((-1,570),(-17,550),(-40,535))
61 & flex((-40,535),(-45,510),(-60,477))
62 & flex((-60,477),(-20,510),(40,512))
63 & flex((40,512),(31,532),(8,550),(-1,570)) & cycle;
64 branch4=flex((0,509),(-14,492),(-32,481))
65 & flex((-32,481),(-42,455),(-62,430))
66 & flex((-62,430),(-20,450),(42,448))
67 & flex((42,448),(38,465),(4,493),(0,509)) & cycle;
68 branch5=flex((-22,470),(-23,435),(-44,410))
69 & flex((-44,410),(-10,421),(35,420))
70 & flex((35,420),(15,455),(-22,470)) & cycle;
71 branch6=flex((18,375),(9,396),(5,420))
72 & flex((5,420),(-5,410),(-50,375),(-50,350))
73 & flex((-50,350),(-25,375),(18,375)) & cycle;
74 branch7=flex((0,400),(-13,373),(-30,350))
75 & flex((-30,350),(0,358),(30,350))
76 & flex((30,350),(13,373),(0,400)) & cycle;
77 branch8=flex((50,275),(45,310),(3,360))
78 & flex((3,360),(-20,330),(-70,300),(-100,266))
79 & flex((-100,266),(-75,278),(-60,266))
80 & flex((-60,266),(0,310),(50,275)) & cycle;
81 branch9=flex((10,333),(-15,290),(-43,256))
82 & flex((-43,256),(8,262),(58,245))
83 & flex((58,245),(34,275),(10,333)) & cycle;
84 branch10=flex((8,262),(-21,249),(-55,240))
85 & flex((-55,240),(-51,232),(-53,220))
86 & flex((-53,220),(-28,229),(27,235))
87 & flex((27,235),(16,246),(8,262)) & cycle;
88 branch11=flex((0,250),(-25,220),(-70,195))
89 & flex((-70,195),(-78,180),(-90,170))
90 & flex((-90,170),(-5,188),(74,183))
91 & flex((74,183),(34,214),(0,250)) & cycle;
92 branch12=flex((8,215),(-35,175),(-72,155))
93 & flex((-72,155),(-75,130),(-92,110),(-95,88))
94 & flex((-95,88),(-65,117),(-54,104))
95 & flex((-54,104),(10,151),(35,142))
96 ..flex((42,130),(60,123),(76,124))
97 & flex((76,124),(62,146),(26,180),(8,215)) & cycle;
98 %
99 for i:=0 upto 12:
100 branch[i]:=neg_turn branch[i] shifted (150,50) scaled (w/300);
101 endfor
102 oval=superellipse((w,1/2h),(1/2w,h),(0,1/2h),(1/2w,0),4/5);
103 %
104 % remove overlaps and (optionally) show |turningnumber|s and |turn_check|s:
105 remove_overlap (make_list(0,12)branch,oval)() R;
106 if known show_turningnumbers_and_turn_checks:
107 begingroup
108 interim autorounding:=0;
109 show (turningnumber(branch1), turningnumber(reverse branch1));
110 for i:=1 upto R.num: show i,(turningnumber R[i],check_turn R[i]); endfor;
111 endgroup;
112 fi
113 %
114 % begin export to EPS:
115 find_BB oval;
116 write_preamble jobname;
117 fix_line_join 1; fix_line_cap 1;
118 fix_line_width 1/50pt;
119 % paint the picture:
120 fix_fill_cmyk 0,0,0,1/6;
121 fill_C make_list(1,R.num)R;
122 for i:=1 upto R.num:
123 if proofing=0:
124 fix_draw_cmyk if check_turn(R[i])>0: 0,1,1,0 else: 1,1,0,0 fi;
125 draw_C R[i];
126 else:
127 for j:=0 upto length(R[i])-1:
128 makelabel(decimal(j) & "/" & decimal(i),point j of R[i]);
129 endfor
130 fi
131 endfor
132 %
133 % mark (optionally) dangerously close points:
134 if known mark_trunk_close_points:
135 fix_fill_cmyk 0,0,0,1; fix_draw_cmyk 0,0,0,1;
136 for j:=13,14,17,18:
137 z[j]=point TIME_1tim[j] of PATH_1;
138 fill_C fullcircle scaled 1/50pt shifted z[j];
139 endfor
140 z.a=(1pt,0); z.b=(1/20pt,0); z.c=(1/5pt,1/10pt); z.d=(1/5pt,-1/10pt);
141 for zz:=1/2[z13,z14],1/2[z17,z18]:
142 draw_C (zz-z.a)--(zz-z.b), (zz-z.c)--(zz-z.b)--(zz-z.d);
143 endfor
144 fi
145 % end export to EPS:
146 write_postamble;
147 endchar;
148 end.
149 %%\end
150