Debian Codegraph @

texmf-dist/fonts/source/public/bartel-chess-fonts/pkpawn.mf

raw
1 % This is
2 % pkpawn.mf
3 %
4 % Copyright (C) 1989-92 by Elmar Bartel.
5 %
6 % This program is free software; you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation; either version 1, or (at your option)
9 % any later version.
10 %
11 % This program is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with this program; if not, write to the Free Software
18 % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 % This is the oldest part of all my the MF-sources.
21 % I started Metafonting with this figure.
22 % ElB.
23
24 %-----------------------------------------------------------
25 % This macro depends on some global sizes:
26 % thin, BottomSpace, BottomWidth, sidewith
27 % The values are defined as basic sizes of the Chess Characters
28
29 def PawnShape(expr wbf,hbf,wmf,hmf,wtf,htf,ibm,imt) =
30 %begingroup
31 %save wb,wm,wt,hb,hm,ht,interbm,intermt;
32 numeric wb,wm,wt,hb,hm,ht,interbm,intermt;
33 wb = BottomWidth*wbf; % width of bottom ellipse
34 hb = hbf*wb; % hight of bottom ellipse
35 wm = wmf*wb; hm = hmf*wm; % width and hight of middle ellipse
36 wt = wtf*wb; ht = htf*wt; % width and hight of top ellipse
37 interbm = ibm*thin; % amount of intersection of bottom
38 % and middle
39 intermt = imt*thin; % amount of intersection of middle
40 %and top
41 %save superb,superm,supert;
42 numeric superb,superm,supert;
43 superb=.75;
44 superm=.75;
45 supert=.75;
46
47 %save topb,topm,topt;
48 numeric topb,topm,topt;
49 topb=BottomSpace+hb;
50 topm=topb+hm-interbm;
51 topt=topm+ht-intermt;
52
53 %screenrule((0,BottomSpace),(qs,BottomSpace));
54 %screenrule(((qs-wb)/2,0),((qs-wb)/2,qs));
55 %screenrule(((qs+wb)/2,0),((qs+wb)/2,qs));
56
57 %screenrule((0,topb),(qs,topb));
58 %screenrule((0,topm),(qs,topm));
59 %screenrule((0,topt),(qs,topt));
60
61 %save bp,mp,tp;
62 numeric bp,mp,tp;
63 path bp,mp,tp,PawnPath;
64
65 %save x,y,z;
66 %pair z[]b,x[]b,y[]b;
67 %pair z[]m,x[]m,y[]m;
68 %pair z[]t,x[]t,y[]t;
69
70 bot rt z1b = ((qs+wb)/2, BottomSpace);
71 bot lft z3b = ((qs-wb)/2, BottomSpace);
72 bot y4b + hb = top y2b - hb = BottomSpace;
73 x2b = x4b = qs/2;
74 bp=superellipse(z1b,z2b,z3b,z4b,superb);
75 bp:= subpath(0,4) of bp;
76
77 rt x1m - wm/2 = lft x3m + wm/2 = qs/2;
78 top y2m = bot y4m + hm = topm;
79 y1m = y3m = (y2m+y4m)/2;
80 x2m = x4m = qs/2;
81 mp=superellipse(z1m,z2m,z3m,z4m,superm);
82
83 rt x1t - wt/2 = lft x3t + wt/2 = qs/2;
84 top y2t = bot y4t + ht = topt;
85 y1t = y3t = (y2t+y4t)/2;
86 x2t = x4t = qs/2;
87 tp=superellipse(z1t,z2t,z3t,z4t,supert);
88
89 % compute the intersectiontimes on the right side of the pawn
90 % The pathtimes of superellipses range from 0 to 8
91
92 %save scbr,scmbr,scmtr,sctr;
93 numeric scbr,scmbr,scmtr,sctr;
94 scbr = xpart (bp intersectiontimes (subpath(6,8)of mp));
95 scmbr = xpart (mp intersectiontimes (subpath(0,2)of bp));
96 scmtr = xpart (mp intersectiontimes (subpath(6,8)of tp));
97 sctr = xpart (tp intersectiontimes (subpath(0,2)of mp));
98
99 % here is a macro to mirror pathtimes of superellipses on y-axis
100 def mr(expr v) =
101 if v > 4: 12-v;
102 else: 4-v;
103 fi
104 enddef;
105
106 % Now the left intersectionpoints
107 %save scbl,scmbl,scmtl,sctl;
108 numeric scbl,scmbl,scmtl,sctl;
109 scbl = mr(scbr);
110 scmbl = mr(scmbr);
111 scmtl = mr(scmtr);
112 sctl = mr(sctr);
113
114 PawnPath:=subpath(0,scbr)of bp ..
115 subpath(scmbr,(8+scmtr)) of mp ..
116 subpath(sctr,8+sctl) of tp ..
117 subpath(scmtl,scmbl) of mp ..
118 subpath(scbl,4) of bp;
119 %endgroup
120
121 enddef;
122 %-----------------------------------------------------------
123 def MakePawnPath =
124 pickup chess_pen;
125 if unknown PawnPath:
126 % wb = qs - 2*sidespace; % width of bottom ellipse
127 % hb = hbf*wb; % hight of bottom ellipse
128 % wm = wmf*wb; hm = hmf*wm; % width and hight of middle
129 % ellipse
130 % wt = wtf*wb; ht = htf*wt; % width and hight of top
131 % ellipse
132 %
133 % wbf, hbf, ,wmf, hmf, wtf, htf, ibm, imt
134 %PawnShape( .80, .50, .55, .85, .3, 1.0, 2.0, 1.2);
135 %PawnShape( .85, .55, .60, .90, .4, 1.0, 2.0, 1.2);
136 PawnShape( .83, .50, .57, .85, .3, 1.0, 2.0, 1.2);
137 fi
138 enddef;
139 %------------------------------------------------------------
140 def CorrectPawnEdges =
141 pickup sqr;
142 drawdot(z1b);
143 drawdot(z3b);
144 enddef;
145 %-----------------------------------------------------------
146
147 %we have to define six essential characters:
148 % WoW NoW BoW WoB NoB BoB
149 %Pawn 0 6 12 18 24 30
150 %Knight 1 7 13 19 25 31
151 %Bishop 2 8 14 20 26 32
152 %Rook 3 9 15 21 27 33
153 %Queen 4 10 16 22 28 34
154 %King 5 11 17 23 29 35
155
156 % All these cases are repeated three more times:
157 % Left turned, Right turned and upside down
158 %------------------------------------------
159
160
161 def MakeWhitePawn =
162 pickup chess_pen;
163 clearit;
164 MakePawnPath;
165 draw PawnPath -- cycle;
166 cullit;
167 WhiteMan:= currentpicture;
168 enddef;
169
170 def MakeBlackPawn =
171 pickup chess_pen;
172 clearit;
173 MakePawnPath;
174 filldraw PawnPath -- cycle;
175 cullit;
176 BlackMan:= currentpicture;
177 enddef;
178
179 def MakeOuterShape =
180 pickup frame_pen;
181 clearit;
182 filldraw PawnPath -- cycle;
183 cullit;
184 OuterShape:= currentpicture;
185 enddef;
186
187 MakeWhitePawn;
188 MakeBlackPawn;
189 MakeNeutral(WhiteMan, BlackMan);
190 MakeOuterShape;
191
192 beginchar(Pawn+White+OnWhite, qs#, qs#, 0);
193 "White pawn on white field";
194 currentpicture:= WhiteMan;
195 endchar;
196
197 beginchar(Pawn+White+OnWhite+LeftTurned, qs#, qs#, 0);
198 "White pawn on white field rotated to the left";
199 currentpicture:= TurnLeft(WhiteMan);
200 endchar;
201
202 beginchar(Pawn+White+OnWhite+RightTurned, qs#, qs#, 0);
203 "White pawn on white field rotated to the right";
204 currentpicture:= TurnRight(WhiteMan);
205 endchar;
206
207 beginchar(Pawn+White+OnWhite+UpSideDown, qs#, qs#, 0);
208 "White pawn on white field upside down";
209 currentpicture:= TurnUpSideDown(WhiteMan);
210 endchar;
211
212 beginchar(Pawn+Black+OnWhite, qs#, qs#, 0);
213 "Black pawn on white field";
214 currentpicture:= BlackMan;
215 endchar;
216
217 beginchar(Pawn+Black+OnWhite+LeftTurned, qs#, qs#, 0);
218 "Black pawn on white field rotated to the left";
219 currentpicture:= TurnLeft(BlackMan);
220 endchar;
221
222 beginchar(Pawn+Black+OnWhite+RightTurned, qs#, qs#, 0);
223 "Black pawn on white field rotated to the right";
224 currentpicture:= TurnRight(BlackMan);
225 endchar;
226
227 beginchar(Pawn+Black+OnWhite+UpSideDown, qs#, qs#, 0);
228 "Black pawn on white field upside down";
229 currentpicture:= TurnUpSideDown(BlackMan);
230 endchar;
231
232 beginchar(Pawn+Neutral+OnWhite, qs#, qs#, 0);
233 "Neutral pawn on white field";
234 currentpicture:= NeutralMan;
235 endchar;
236
237 beginchar(Pawn+Neutral+OnWhite+LeftTurned, qs#, qs#, 0);
238 "Neutral pawn on white field rotated to the left";
239 currentpicture:= TurnLeft(NeutralMan);
240 endchar;
241
242 beginchar(Pawn+Neutral+OnWhite+RightTurned, qs#, qs#, 0);
243 "Neutral pawn on white field rotated to the right";
244 currentpicture:= TurnRight(NeutralMan);
245 endchar;
246
247 beginchar(Pawn+Neutral+OnWhite+UpSideDown, qs#, qs#, 0);
248 "Neutral pawn on white field upside down";
249 currentpicture:= TurnUpSideDown(NeutralMan);
250 endchar;
251
252 beginchar(Pawn+White+OnBlack, qs#, qs#, 0);
253 "White pawn on black field";
254 MakeBlackField;
255 currentpicture:= currentpicture - OuterShape;
256 cullit;
257 currentpicture:= currentpicture + WhiteMan;
258 endchar;
259
260 beginchar(Pawn+White+OnBlack+LeftTurned, qs#, qs#, 0);
261 "White pawn on black field turned to the left";
262 MakeBlackField;
263 currentpicture:= currentpicture - TurnLeft(OuterShape);
264 cullit;
265 currentpicture:= currentpicture + TurnLeft(WhiteMan);
266 endchar;
267
268 beginchar(Pawn+White+OnBlack+RightTurned, qs#, qs#, 0);
269 "White pawn on black field turned to the right";
270 MakeBlackField;
271 currentpicture:= currentpicture - TurnRight(OuterShape);
272 cullit;
273 currentpicture:= currentpicture + TurnRight(WhiteMan);
274 endchar;
275
276 beginchar(Pawn+White+OnBlack+UpSideDown, qs#, qs#, 0);
277 "White pawn on black field upsidedown";
278 MakeBlackField;
279 currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
280 cullit;
281 currentpicture:= currentpicture + TurnUpSideDown(WhiteMan);
282 endchar;
283
284 beginchar(Pawn+Neutral+OnBlack, qs#, qs#, 0);
285 "Neutral pawn on black field";
286 MakeBlackField;
287 currentpicture:= currentpicture - OuterShape;
288 cullit;
289 currentpicture:= currentpicture + NeutralMan;
290 endchar;
291
292 beginchar(Pawn+Neutral+OnBlack+LeftTurned, qs#, qs#, 0);
293 "Neutral pawn on black field turned to the left";
294 MakeBlackField;
295 currentpicture:= currentpicture - TurnLeft(OuterShape);
296 cullit;
297 currentpicture:= currentpicture + TurnLeft(NeutralMan);
298 endchar;
299
300 beginchar(Pawn+Neutral+OnBlack+RightTurned, qs#, qs#, 0);
301 "Neutral pawn on black field turned to the right";
302 MakeBlackField;
303 currentpicture:= currentpicture - TurnRight(OuterShape);
304 cullit;
305 currentpicture:= currentpicture + TurnRight(NeutralMan);
306 endchar;
307
308 beginchar(Pawn+Neutral+OnBlack+UpSideDown, qs#, qs#, 0);
309 "Neutral pawn on black field upsidedown";
310 MakeBlackField;
311 currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
312 cullit;
313 currentpicture:= currentpicture + TurnUpSideDown(NeutralMan);
314 endchar;
315
316 beginchar(Pawn+Black+OnBlack, qs#, qs#, 0);
317 "Black pawn on black field";
318 MakeBlackField;
319 currentpicture:= currentpicture - OuterShape;
320 cullit;
321 currentpicture:= currentpicture + BlackMan;
322 endchar;
323
324 beginchar(Pawn+Black+OnBlack+LeftTurned, qs#, qs#, 0);
325 "Black pawn on black field turned to the left";
326 MakeBlackField;
327 currentpicture:= currentpicture - TurnLeft(OuterShape);
328 cullit;
329 currentpicture:= currentpicture + TurnLeft(BlackMan);
330 endchar;
331
332 beginchar(Pawn+Black+OnBlack+RightTurned, qs#, qs#, 0);
333 "Black pawn on black field turned to the right";
334 MakeBlackField;
335 currentpicture:= currentpicture - TurnRight(OuterShape);
336 cullit;
337 currentpicture:= currentpicture + TurnRight(BlackMan);
338 endchar;
339
340 beginchar(Pawn+Black+OnBlack+UpSideDown, qs#, qs#, 0);
341 "Black pawn on black field upsidedown";
342 MakeBlackField;
343 currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
344 cullit;
345 currentpicture:= currentpicture + TurnUpSideDown(BlackMan);
346 endchar;