Debian Codegraph @

texmf-dist/doc/generic/mfpic/examples/forfun.tex

raw
1 % File: forfun.tex
2 % A part of mfpic 1.10 2012/12/03
3 %
4 \nopagenumbers
5 \input mfpic.tex
6 \usemetapost
7 \usetruebbox
8 \opengraphsfile{fun}
9
10 \mfpicunit=2bp
11
12 \noindent
13 \mfpic{-1.25}{118.5}{-11.25}{40}
14 %
15 % "meta"-ness:
16 %
17 \mfsrc{h:=25; % height of "m" These are graph units
18 s:=10; % width of stems
19 }
20 %
21 % Calculate key points:
22 %
23 % "m"
24 %
25 \mfsrc{%
26 z1=(0,0);
27 y1=y2=y5=y6=y9=y10;
28 x2-x1=x6-x5=x10-x9=s;
29 x6-x1=x10-x5=h;
30 z15-z1=z3-z2=z4-z5=z7-z6=z8-z9=z11-z10=(0,h/2);
31 y12=y1+h; x12=.5[x6,x9];
32 y14=y12; x14=.5[x2,x5];
33 z13= arcppp(z7,z14,z15) intersectionpoint arcppp(z11,z12,z4);}
34 %
35 % "f"
36 %
37 \mfsrc{%
38 z21=z10; % start "f" at "m"'s end
39 z22=z21+(s,0);
40 z23=z22+(0,h-s);
41 z24=z23+(3s/4,0);
42 z25=z24+(0,s);
43 z26=z23+(0,s);
44 z27=z26+(0,s/4);
45 z28=z27+(s/4,0)+ (s/4)*dir(30);
46 z29=z28+s*dir(30);
47 x30=x21; y30=y27;}%
48 %
49 % "p"
50 %
51 \mfsrc{%
52 x31=x24;
53 y31=y21;
54 z32=z31-(0,s);
55 z33=z32+(s,0);
56 z35=(x33,h/2);
57 z39=z31+(h,h)/2; %center of round part
58 z34=(z33--z35) intersectionpoint (fullcircle scaled h shifted z39);
59 z36=z39+(h/2,0);
60 z37=z31+(0,h/2);}%
61 %
62 % "i"
63 %
64 \mfsrc{%
65 z41=(x36,y31);
66 z42=z41+(s,0);
67 z43=z42+(0,h);
68 z44=z41+(0,h);
69 x45=0.5[x41,x42]; y45=y43 + s/2 +3/50;}% Center of dot
70 %
71 % "c"
72 %
73 \mfsrc{%
74 z51=z42;
75 z52=z51+(h,h)/2; %center
76 z53=z52+(h/2)*dir(15);
77 z54=z52-(h/2,0);
78 z55=z52+(h/2)*dir(-15);
79 z56=z52+(s/4)*dir(-15);
80 z57=z52-(s/4,0);
81 z58=z52+(s/4)*dir(15);}%
82 %
83 \penwd{2.5*\the\mfpicunit}
84 \mfsrc{%
85 %
86 % Calculate bounding box
87 %
88 % Need to account for half the thickness of pen;
89 % penwd is in absolute units so we need to convert.
90 % This is a displacement, so use invvconv (not invzconv):
91 begingroup
92 save border,ll,ur;
93 pair border,ll,ur; border:= invvconv((penwd,penwd))/2;
94 ll=(0,y32)-border;
95 ur=(x55,y27+5s/4)+border;}
96 %
97 \gfill[yellow]\rect{ll,ur} % background
98 \mfsrc{endgroup;}
99 %
100 \fillcolor{blue}
101 \drawcolor{green}
102 %
103 % "m"
104 \mftitle{m}
105 \draw\gfill\lclosed
106 \connect
107 \lines{z15,z1,z2,z3}
108 \arc[s]{z3,z4,-180}
109 \lines{z4,z5,z6,z7}
110 \arc[s]{z7,z8,-180}
111 \lines{z8,z9,z10,z11}
112 \arc[t]{z11,z12,z13}
113 \arc[t]{z13,z14,z15}
114 \endconnect
115 %
116 % "f"
117 \mftitle{f}
118 \draw\gfill\lclosed
119 \connect
120 \lines{z21,z22,z23,z24,z25,z26,z27}
121 \arc[s]{z27,z28,-150}
122 \lines{z28,z29}
123 \arc[s]{z29,z30,150}
124 \endconnect
125 %
126 % "p"
127 \mftitle{p}
128 \draw\gfill\lclosed
129 \connect
130 \lines{z31,z32,z33,z34}
131 \arc[t]{z34,z36,z37}
132 \endconnect
133 \draw\gfill[yellow]\circle{z39,(h/2-s)}
134 %
135 % "i"
136 \mftitle{i}
137 \draw\gfill\polygon{z41,z42,z43,z44}
138 \draw\gfill\circle{z45,s/2}
139 %
140 % "c"
141 \mftitle{c}
142 \draw\gfill\lclosed
143 \connect
144 \arc[t]{z53,z54,z55}
145 \arc[t]{z56,z57,z58}
146 \endconnect
147 % uncoment to exhibit the points
148 %\pointsize2bp
149 %\pointfillfalse
150 %\penwd{.2pt}
151 %\point{z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14}
152 %\point{z21,z22,z23,z24,z25,z26,z27,z28,z29,z30}
153 %\point{z31,z32,z33,z34,z35,z36,z37}
154 %\point{z41,z42,z43,z44,z45}
155 %\point{z51,z52,z53,z54,z55,z56,z57,z58}
156 % done
157 \endmfpic
158
159 \closegraphsfile % {fun}
160 \bye