Debian Codegraph @

texmf-dist/fonts/source/public/skak/skakbase.mf

raw
1 % This is `skakbase.mf' version 1.0 as of 6/99
2 % based on original work by Piet Tutelaers
3 % Modified by Torben Hoffmann: smaller pieces and nicer looking knight
4
5 % In this file all pieces are defined.
6 % The points defining a piece are all in the unitsquare
7 % (0,0)--(0,1)--(1,1)--cycle.
8
9
10 def g(expr x) = (.5+(x-.5)*.87) enddef;
11 def f(expr x,y) = (g(x)+figshift,g(y)+lift) enddef;
12
13 def dark_square(expr D) =
14 clearit; L:=min(D/4, 9); delta:=1/L;
15 pickup fine_pen;
16 for i=1 upto min(D/4,9):
17 draw (0,delta*i*D)--(D-delta*i*D,D);
18 draw (delta*i*D,0)--(D,D-delta*i*D);
19 endfor;
20 draw (0,0)--(D,D);
21 enddef;
22
23 def erase_square(expr D, col, row) =
24 currentpicture:=board;
25 erase fill (0,0)--(0,1)--(1,1)--(1,0)--cycle scaled D shifted(col*D, row*D);
26 board:=currentpicture;
27 enddef;
28
29 def empty_board(expr D) =
30 picture board; path border;
31 border = ((0,0)--(1,0)--(1,1)--(0,1)--cycle);
32 dark_square(D); board:=nullpicture;
33 for i=0 upto M-1:
34 for j=0 upto M-1:
35 if not odd(i+j): addto board also currentpicture shifted (D*i,D*j) fi;
36 endfor
37 endfor;
38 clearit;
39 pickup border_pen;
40 draw border scaled (M*D);
41 addto board also currentpicture;
42 currentpicture:=board;
43 enddef;
44
45 % def reflect(text t) =
46 % forsuffixes $=t: z$'=z$ reflectedabout (z1,z2); endfor;
47 % enddef;
48 def reflect(text t) =
49 forsuffixes $=t: x$'=1-x$+2figshift; y$'=y$; endfor;
50 enddef;
51
52 def opr(suffix $) = (g(x$+thick#/d#), y$) enddef; % one point right
53 def opl(suffix $) = (g(x$-thick#/d#), y$) enddef; % one point left
54 def opu(suffix $) = (x$, g(y$+thick#/d#)) enddef; % one point up
55 def opd(suffix $) = (x$, g(y$-thick#/d#)) enddef; % one point down
56 def opur(suffix $) = f(x$+thick#/d#,y$+thick#/d#) enddef;
57 % one point up and right
58 def opul(suffix $) = f(x$-thick#/d#,y$+thick#/d#) enddef;
59 % one point up and left
60
61
62
63 vardef K(expr D, col, row) =
64 clearxy;
65 path cross_bar, crown, crown_top, crown_left, crown_right, crown_lower,
66 crown_top_inner, crown_left_inner, crown_right_inner;
67 def moved = scaled D shifted (col*D, row*D) enddef;
68
69 pickup hairline_pen;
70 % draw cross
71 z1=f(.5,.96); z2=f(.5,.8); z11=f(.42,.9); reflect(11);
72 % cutdraw (z1--z2) moved; cutdraw (z11--z11') moved;
73 draw (z1--z2) moved; draw (z11--z11') moved;
74 % top part of crown
75 z3=f(.5,.38); z21=f(.475,.5); z22=f(.45,.575); z23=f(.45,.775);
76 reflect(21,22,23);
77 crown_top= ((z3..z21..z22..z23..z2..z23'..z22'..z21'..z3) & cycle);
78 % left and right part
79 z31=z21; z32=z22; z33=f(.32,.67); z34=f(.13,.69); z35=f(.07,.55);
80 z36=f(.13,.45); z37=f(.2,.34);
81 reflect(31, 32, 33, 34, 35, 36, 37);
82 crown_left=(z3..z31..z33..z34..z35..z36..z37);
83 crown_right=(z37'..z36'..z35'..z34'..z33'..z31'..z3);
84 % lower part of the crown
85 % z6=f(.5,.095); z61=f(.27,.12); z62=f(.2,.15); z63=f(.21,.23);
86 z6=f(.5,.095); z61=(x62,.09); z62=f(.2,.15); z63=f(.21,.23);
87 reflect(61, 62, 63);
88 % crown_lower= ((z37--z63) & (z63--z62) & (z62..z61..z6..z61'..z62') &
89 crown_lower= ((z37--z63) & (z63--z62) & (z62..controls z61 and z61'..z62') &
90 (z62'--z63') & (z63'--z37') & (z37'..z3..z37) & cycle);
91 % draw contour of crown
92 pickup thin_pen;
93 crown= crown_left & z37..z3..z37' & crown_right & cycle;
94 if background=dark: erase fill crown moved;
95 erase fill crown_top moved;
96 erase fill crown_lower moved;fi;
97 draw crown moved; draw crown_top moved;
98 if color=black:
99 z121=f(.5,.5); z123=f(.45,.675); z102=f(.5,.77);
100 reflect(123);
101 crown_top_inner = (z121{curl 0}..z123..z102..z123'..{curl 0}z121 & cycle);
102 z131=f(.45,.5); z133=f(.32,.64); z134=f(.13,.66); z135=f(.10,.55);
103 z136=f(.16,.45); z137=f(.22,.36); z103=f(.475,.4);
104 crown_left_inner= ((z103..z131..z133..z134..z135..z136..z137)
105 & (z137..{right}z103) & cycle);
106 crown_right_inner=crown_left_inner reflectedabout (z1,z2);
107 fill crown_top_inner moved;
108 fill crown_left_inner moved;
109 fill crown_right_inner moved;
110 fill crown_lower moved;
111 else: draw crown_lower moved;
112 fi;
113 % draw inner parts
114 z4=f(.5,.28); z5=f(.5,.21);
115 if color=white:
116 draw (z37..z3..z37') moved;
117 draw (z63..z4..z63') moved;
118 draw (z62..z5..z62') moved;
119 else: pickup thick_pen;
120 erase draw (opr(37)..z3..opl(37')) moved;
121 erase draw (opr(63)..z4..opl(63')) moved;
122 erase draw (opr(62)..z5..opl(62')) moved;
123 fi;
124 enddef;
125
126 vardef Q(expr D, col, row) =
127 clearxy;
128 path crown_top, crown, crown_lower;
129 def moved = scaled D shifted (col*D, row*D) enddef;
130
131 pickup thin_pen;
132 % top part of crown
133 z1=f(.5,.92); z2=f(.5,.5); z11=f(.42,.46); z12=f(.275,.88);
134 z13=f(.25,.44); z14=f(.075,.8); z15=f(.125,.4);
135 reflect(11,12,13,14,15);
136 crown_top = (z15'--z14'--z13'--z12'--z11'--z1--z11--z12--z13--z14--z15);
137 % lower part of the crown
138 % z6=f(.5,.0775); z61=f(.25,.1); z62=f(.18,.125); z63=f(.22,y62+1/3(y15-y62));
139 z6=f(.5,.0775); z61=f(.18,0.05); z62=f(.18,.125); z63=(g(.22)+figshift,y62+1/3(y15-y62));
140 z64=(g(.19)+figshift,y62+2/3(y15-y62)); z65=(g(.15)+figshift,y64+1/3(y15-y64));
141 reflect(61,62,63,64,65);
142 % crown_lower= ((z15--z64) & (z64--z63) & (z63--z62) &
143 crown_lower= ((z15..z65..z64) & (z64..z63..z62) &
144 (z62..controls z61 and z61'..z62') &
145 (z62'..z63'..z64') & (z64'..z65'..z15'));
146 % draw contour of crown
147 crown= (crown_top & crown_lower & cycle);
148 if background=dark:
149 if color=white: erase fill crown moved; fi; fi;
150 if color=white: draw crown moved;
151 forsuffixes $:=1,12,12',14,14':
152 erase fill (fullcircle scaled .1 shifted z$) moved;
153 draw (fullcircle scaled .1 shifted z$) moved; endfor;
154 else: fill crown moved;
155 forsuffixes $:=1,12,12',14,14':
156 fill (fullcircle scaled .1 shifted z$) moved; endfor; fi;
157 % draw inner parts
158 z3=(.5+figshift,y5+(y64-y62)); z4=(.5+figshift,y5+(y63-y62)); z5=f(.5,.17);
159 z67=(x62,y62+.7(y62-y61));
160 reflect(67);
161 if color=white: draw (z64..z3..z64') moved; draw (z63..z4..z63') moved;
162 % draw (z62..z5..z62') moved;
163 draw (z62..controls z67 and z67'..z62') moved;
164 z21=z11; z22=f(.325,.475); z23=z13; z24=f(.175,.44); z25=z15;
165 reflect(21,22,23,24,25);
166 draw ((z2..z21..z22) & (z22..z23..z24) & (z24--z25)) moved;
167 draw ((z2..z21'..z22') & (z22'..z23'..z24') & (z24'--z25')) moved;
168 else: pickup thick_pen;
169 erase draw (opr(64)..z3..opl(64')) moved;
170 erase draw (opr(63)..z4..opl(63')) moved;
171 z72=f(.25,.14); z73=(x72+0.08,y72+.9(y67-y62));
172 reflect(72,73);
173 % erase draw (opr(62)..z5..opl(62')) moved;
174 erase draw (z72..controls z73 and z73'..z72') moved;
175 fi;
176 enddef;
177
178
179 vardef N(expr D, col, row) =
180 clearxy;
181 path knight, ear, eye, nose, mouth, neck;
182 def moved = scaled D shifted (col*D, row*D) enddef;
183
184 pickup thin_pen;
185 % the knight's contour
186 z1=f(.5,.82); z2=f(.5,.075); z11=f(.45,.93); z12=f(.375,.85);
187 z13=f(.25,.925);
188 z14=f(.26,.8); z15=f(.22,.75); z16=f(.18,.7); z17=f(.18,.66); z18=f(.07,.42);
189 z19=f(.07,.36); z20=f(.14,.3); z21=f(.17,.3); z22=f(.175,.275);
190 z23=f(.225,.28);
191 z24=f(.29,.38); z25=f(.41,.46); z26=f(.49,.51); z27=f(.435,.295);
192 % z28=f(.32,.165);
193 % z29=(.31,y2); z30=(.93,y2); z31=(.87,.5); z32=(.7,.78);
194 z28=f(.34,.18);
195 z29=(g(.33)+figshift,y2); z30=(g(.92)+figshift,y2); z31=f(.85,.5); z32=f(.73,.72);
196 knight = ((z1--z11--z12--z13--z14) &
197 (z14..z15..z16..z17..z18..z19..z20..z21) &
198 (z21..z22..z23..z24..z25..z26) &
199 (z26..z27..z28..z29) & (z29--z30) &
200 (z30..z31..z32..z1) &cycle);
201 % draw contour of knight
202 if color=white: erase fill knight moved;
203 draw knight moved;
204 else: fill knight moved; fi;
205 % draw inner parts
206 z4=f(.22,.62); z41=f(.25,.67); z42=f(.29,.705); z43=f(.31,.7); z44=f(.3,.68);
207 eye = (z4..z41..z42..z43 & z43..z44..z4 & cycle);
208 z5=f(.1,.36); z51=f(.1,.39); z52=f(.135,.43); z53=f(.15,.4); z54=f(.13,.38);
209 nose = (z5..z51..z52..z53..z54..z5 &cycle);
210 if color=white: z21'=f(.2,.34); draw (z21'--z21) moved; %mouth
211 z26'=f(.54,.63); draw (z26'..z26{z24-z26}) moved; %neck
212 draw (z12--z14) moved; % ear
213 fill eye moved; fill nose moved;
214 else: erase fill eye moved; erase fill nose moved; fi;
215 % z30'=z30 + f(-thick#/d#,thick#/d#); pickup thick_pen
216 z30'=opul(30); pickup thick_pen
217 erase draw (.4[opd(1),z1]..opd(32)..1/2[opl(31),z31]..1/2[z30',z30]) moved; % mane
218 enddef;
219
220 vardef B(expr D, col, row) =
221 clearxy;
222 path top, hat, brim, mitre, stole;
223 def moved = scaled D shifted (col*D, row*D) enddef;
224
225 pickup thin_pen;
226 % the top circle
227 z1=f(.5,.85); z2=f(.5,.8);
228 top = (fullcircle scaled .1 shifted z1);
229 if color=white: erase fill top moved; draw top moved;
230 else: fill top moved; fi;
231 % the hat
232 z3=f(.5,.43); z21=f(.27,.57); z31=f(.35,.4); reflect(21,31);
233 hat = (z31'..z21'..z2{(-1,1)}) & (z2{(-1,-1)}..z21..z31);
234 % the brim
235 z4=f(.5,.33); z5=f(.5,.23);
236 z41=f(.32,.28); reflect(41);
237 brim = ((z31--z41) & (z41..z5..z41') & (z41'--z31'));
238 % the stole
239 z6=f(.5,.15); z7=f(.5,.3); z61=f(.44,.12); z62=f(.25,.1); z63=f(.15,.05);
240 z64=f(.09,.11); z65=f(.25,.18); z66=f(.44,.2);
241 reflect(61,62,63,64,65,66);
242 stole = ((z7..z66..z65..z64) & (z64--z63) & (z63..z62..z61..z6) &
243 (z6..z61'..z62'..z63') & (z63'--z64') & (z64'..z65'..z66'..z7) &cycle);
244 % the mitre
245 mitre = (hat & brim & cycle);
246 if background=dark:
247 if color=white: erase fill mitre moved;
248 erase fill stole moved; fi; fi;
249 if color=black: fill mitre moved; fill stole moved;
250 else: draw mitre moved; draw stole moved;
251 erase fill mitre moved; draw mitre moved; fi;
252
253 % inner parts of mitre
254 center:=g(.59); width:=g(.065);
255 if color=white: draw (z31..z3..z31') moved; draw (z41..z4..z41') moved;
256 draw (f(.5,center-width)--f(.5,center+width)) moved;
257 draw (f(.5-width,center)--f(.5+width,center)) moved;
258 else: pickup thick_pen;
259 erase cutdraw (opr(31)..z3..opl(31')) moved;
260 erase cutdraw (opr(41)..z4..opl(41')) moved;
261 erase cutdraw (f(.5,center-width)--f(.5,center+width)) moved;
262 erase cutdraw (f(.5-width,center)--f(.5+width,center)) moved;
263 fi;
264 enddef;
265
266 vardef p(expr D, col, row) =
267 clearxy;
268 path pawn;
269 def moved = scaled D shifted (col*D, row*D) enddef;
270
271 pickup thin_pen;
272 % the pawn's contour
273 % z1=(.5,.9); z2=(.5,.1); z11=(.41,.85); z12=(.46,.73); z13=(.32,.6);
274 % z14=(.41,.46); z15=(.3,.4); z16=(.2,.1);
275
276 z1=f(.5,.9);
277 z2=f(.5,.1); z11=f(.41,.85); z12=f(.46,.73); z13=f(.32,.6);
278 z14=f(.41,.46); z15=f(.3,.4); z16=f(.2,.1);
279 reflect(11,12,13,14,15,16);
280 pawn = ((z12'..z11'..z1..z11..z12) &
281 (z12..z13..z14) &
282 (z14..z15..z16) &
283 (z16--z16') &
284 (z16'..z15'..z14') &
285 (z14'..z13'..z12') & cycle);
286
287 % draw contour of pawn
288 if background=dark:
289 if color=white: erase fill pawn moved; fi; fi;
290 if color=black: fill pawn moved;
291 else: draw pawn moved; fi;
292 enddef;
293
294 % the rook should be shrunk slightly less than the other pieces
295 %def g(expr x) = .5+(x-.5)*.9 enddef;
296 def rookscale(expr x) = .5+(x-.5)*.95 enddef;
297 def j(expr x,y) = (rookscale(x)+figshift,rookscale(y)) enddef;
298
299
300 vardef R(expr D, col, row) =
301 clearxy;
302 path rook;
303 def moved = scaled D shifted (col*D, row*D) enddef;
304
305 pickup thin_pen;
306 % top part of rook
307 z1=j(.5,.86); y15=y14=y11=y1; x15=x16=rookscale(.21)+figshift;
308 x19=x20=rookscale(.225)+figshift; y13=y12=rookscale(.8);
309 y16=rookscale(.725); y17=rookscale(.65); y18=rookscale(.35); y19=rookscale(.26); y20=y21=rookscale(.175); y22=rookscale(.1);
310 x22=x21=rookscale(.175)+figshift; x17=x18=rookscale(.31)+figshift;
311 x13=x14=rookscale(.325)+figshift; x11=x12=rookscale(.43)+figshift;
312 z2=j(.5,.1);
313 reflect(11,12,13,14,15,16,17,18,19,20,21,22);
314 rook = (z11--z12--z13--z14--z15--z16--z17--z18--z19--z20--z21--z22--z22'
315 --z21'--z20'--z19'--z18'--z17'--z16'--z15'--z14'--z13'--z12'--z11'--cycle);
316 % draw contour of rook
317 if background=dark:
318 if color=white: erase fill rook moved; fi; fi;
319 if color=white: draw rook moved; else: fill rook moved; fi;
320 % draw inner parts
321 if color=white: draw (z16--z16') moved; draw (z17--z17') moved;
322 draw (z18--z18') moved; draw (z19--z19') moved;
323 draw (z20--z20') moved;
324 else: pickup thick_pen;
325 erase draw (opr(16)--opl(16')) moved;
326 erase draw (opr(17)--opl(17')) moved;
327 erase draw (opr(18)--opl(18')) moved;
328 erase draw (opr(19)--opl(19')) moved;
329 erase draw (opr(20)--opl(20')) moved; fi;
330 enddef;
331
332
333
334
335
336
337