summaryrefslogtreecommitdiff
path: root/fonts/bartel-chess-fonts/pkknight.mf
blob: de072befeb482b3f09b5e08ec14edd52d7dd80b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
% This is
%               pkknight.mf
%
% Copyright (C) 1989-92  by Elmar Bartel.
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 1, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
def sympoint (expr p,d,a) = 
	% Come to point p in direction d + angel a, and leave symmetrical
	% to d - a This gives us a peak in p pointing in direction d.
	% sharpnes is specified by a. a= 0 no peak, a=90 real peak;

	{dir (angle(d)+a)} p {dir(angle(d)+180-a)}
enddef;

def Ear(expr p,pd,q,qd,a,r,rd) =
	p{pd} .. sympoint(q,qd,a) .. {rd}r
enddef;

def DefineKnightPath =
	% we construct the path from right to left.
	% Ie we begin with the nack and come then to the ears,
	% the nose etc
	z0 = (.35qs,BottomSpace);       % The leftmost bottompoint
	z1 = (qs-SideSpace,BottomSpace); % The right bottom edge
	path Foot;
	Foot = z0 -- z1;
					% z2 will be later defined, it
					% is the connection to the right
					% ear
	z4 = (.5qs,qs-TopSpace);        % The peak of the right ear
	z3 = z4 + (.07qs,-0.15qs);      % The right lower point of the
					% right ear
	z5 = z3 - (.08qs,.01qs );       % The left lower point of the
					% right ear

	% Now comes the definition of the right ear
	% There are two paths:
	%       RightEar:  The complete path for the ear
	%       sRightEar: The subpath for the whole shape
	path RightEar, sRightEar;
	RightEar = Ear(z3,(1,5),z4,(0,1),10,z5,(1,-5));
	sRightEar = subpath (.25,1.75) of RightEar;
	z2 = point 0 of sRightEar;      % The right 
	z6 = point 2 of sRightEar;      % The left connection point of
					% the right ear 

	% Now we can also define the nack
	path Nack;
	Nack = z1{up} .. tension 1 and 1 ..  {left}z2;

	z7 = z6 + (-.1qs,-0.07qs);      % This is the point under the
					% left ear

	% Now the two pathes from the right to the left ear.
	% EarUnderEar, goes from the right ear under the left ear
	% EarToEar connects only the two ears

	path EarUnderEar,EarToEar;
	EarUnderEar= z6{left} .. {-5,-3}z7;
	EarToEar = subpath (0,.5) of EarUnderEar;       

	z8 = point 1 of EarToEar;       % The connection point and the
					% start of the left ear

	% to get easier definition of the following points 
	% we define a line bx from z7 (point under left ear) down to z13
	% (leftmost point of shape) ie the begining of nose and mount

	z13 = (SideSpace,0.35qs);       % The leftmost point of the
					% shape
	pair bx,by;
	bx = z13 - z7;
	by = z13 rotatedabout (z7,-90);

	z9 = z7 + .23bx + .24by;        % the peak of the left ear
	z10= z7 + .11bx + .10by;        % the left point of the left ear

	% Now the path for the leaft ear
	path LeftEar;
	LeftEar= Ear(z8,(-1,5),z9,(-1,1),8,z10,(2,-5));

	z11 = z7 + .4bx + .09by;
	z12 = z7 + .5bx + .05by;

	path Bless;
	Bless = z10{dir(angle(bx)-10)} .. z11 .. z12 .. {down} z13;

	% the points from z14 to z17 are defined via a line nx
	% from z13 to z18
	pair nx,ny;

	z19 = (.25qs,.25qs);
	nx = z19 - z13;
	ny = nx rotatedabout ((0,0),90);

	z14 = z13 + .30nx - .13ny;      % the point between mouth
					% and nose
	z15 = z13 + .63nx - .02ny;      % the upper point of mouth
	z16 = z13 + .72nx + .15ny;      % the inner point of mouth
	z17 = z13 + .77nx - .02ny;      % 
	z18 = z13 + .87nx - .08ny;      %
	z25 = z13 + .22nx + .28ny;      % the location of the nose

	path MouthNose;
	MouthNose = z13 .. z14{nx} .. z15 ... sympoint(z16,(z16-z17),0)
		       ... z17 .. z18 .. z19;

	% the points from z20 to z23 are defined via a line nx
	% from z19 to z23
	pair ux,uy;

	z23 = (.55qs,.61qs);
	ux = z23 - z19;
	uy = z23 rotatedabout (z19,90);

	z20 = z19 + .15ux + .01uy;
	z21 = z19 + .45ux - .05uy;
	z22 = z19 + .88ux - .15uy;
	path UnderMouth, sUnderMouth;
	UnderMouth = z19 ..z20..z21..z22..{up}z23;
	sUnderMouth = subpath (0,3) of UnderMouth;

	z24 = z22 + .06qs*down;
	path ToFoot;
	ToFoot = z22{down} .. z24 .. {down}z0;


	path KnightShape;
	KnightShape = Foot & Nack & sRightEar & EarToEar
			   & LeftEar & Bless & MouthNose
			   & sUnderMouth & ToFoot & cycle;

enddef;

def DefineNosePath(expr p,s) = 
	begingroup
	if proofing >0:
		show p,s;
	fi;
	save z; pair z[];

	z0 + (0,s) = p;
	pair px,py;
	py= p - z0;
	px= py rotated -90;
	z1= z0 + 0.10px + 0.50py;
	z2= z0 + 0.70px + 1.00py;
	z3= z0 + 0.70px + 1.60py;
	z4= z0 + 0.10px + 2.10py;
	z5= z0 - 0.20px + 1.90py;
	z6= z0 - 0.60px + 0.50py;
	z7= z0 - 0.60px + 0.10py;
	z8= z0 - 0.50px + 0.00py;
	forsuffixes i=0,1,2,3,4,5,6,7,8:
		z[i]..
	endfor cycle
	endgroup
enddef;

def EyePath (expr p,s) =
	begingroup
	save z; pair z[];

	z0 + (0,s) = p;
	pair px,py;
	py= p - z0;
	px= py rotated -90;

	z1= z0 + 1.00px + 1.00py;

	z0{0,1} .. {1,0} z1 & z1 {0,-1} .. {-1,0}z0 & cycle
	endgroup
enddef;

def MakeWhiteKnight = 
	clearit;
	pickup chess_pen;
	draw Foot;
	draw RightEar;
	draw EarUnderEar;
	draw LeftEar & Bless & MouthNose & UnderMouth;
	draw ToFoot;
	draw EyePath(z7-(.04qs,.05qs),.03qs);
	filldraw DefineNosePath(z25,.015qs);
	pickup chess_pen xscaled 2 rotated -10; 
	draw ShortenEnd(Nack,thin);
	WhiteMan:= currentpicture;
enddef;

def MakeBlackKnight = 
	clearit;
	pickup chess_pen;

	filldraw KnightShape;
	cullit;
	unfilldraw DefineNosePath(z25,.015qs);
	undraw EyePath(z7-(.04qs,.05qs),.03qs);
	pickup chess_pen scaled .7 rotated -70;
	undraw ShortenPath(ParallelPath(Nack,1.3thin),thin);
	pickup chess_pen scaled .5;
	undraw subpath (3,3.5) of UnderMouth;
	BlackMan:= currentpicture;
enddef;

def MakeKnightSpace =
	clearit;
	pickup frame_pen;
	filldraw KnightShape;
	cullit;
	OuterShape:= currentpicture;
enddef;

DefineKnightPath;
%DefineNosePath(z25,.2qs);

MakeWhiteKnight;
MakeBlackKnight;
MakeNeutral(WhiteMan,BlackMan);
MakeKnightSpace;

%===========================================================

beginchar(Knight+White+OnWhite, qs#, qs#, 0);
	"White knight on white field";
	currentpicture:= WhiteMan;
	labels(z0,z1l,z1,z1r,z2l,z2,z2r);
	labels(z3l,z3,z3l,z4,z5,z6l,z6r);
	labels(z7l,z7,z7r,z8);
endchar;
if proofing = 0:

beginchar(Knight+White+OnWhite+LeftTurned, qs#, qs#, 0);
	"White knight turned to the left on white field";
	currentpicture:= TurnLeft(WhiteMan);
endchar;

beginchar(Knight+White+OnWhite+RightTurned, qs#, qs#, 0);
	"White knight turned to the right on white field";
	currentpicture:= TurnRight(WhiteMan);
endchar;

beginchar(Knight+White+OnWhite+UpSideDown, qs#, qs#, 0);
	"White knight turned upsidedown on white field";
	currentpicture:= TurnUpSideDown(WhiteMan);
endchar;

%===========================================================

beginchar(Knight+White+OnBlack, qs#, qs#, 0);
	"White knight on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - OuterShape;
	cullit;
	currentpicture:= currentpicture + WhiteMan;
endchar;

beginchar(Knight+White+OnBlack+LeftTurned, qs#, qs#, 0);
	"White knight turned to the left on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnLeft(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnLeft(WhiteMan);
endchar;

beginchar(Knight+White+OnBlack+RightTurned, qs#, qs#, 0);
	"White knight turned to the right on black field";
	MakeBlackField;
	currentpicture:= currentpicture - TurnRight(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnRight(WhiteMan);
endchar;

beginchar(Knight+White+OnBlack+UpSideDown, qs#, qs#, 0);
	"White knight turned upsidedown on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnUpSideDown(WhiteMan);
endchar;

%===========================================================

beginchar(Knight+Neutral+OnWhite, qs#, qs#, 0);
	"Neutral knight on white field";
	currentpicture:= NeutralMan;
endchar;

beginchar(Knight+Neutral+OnWhite+LeftTurned, qs#, qs#, 0);
	"Neutral knight turned to the left on white field";
	currentpicture:= TurnLeft(NeutralMan);
endchar;

beginchar(Knight+Neutral+OnWhite+RightTurned, qs#, qs#, 0);
	"Neutral knight turned to the right on white field";
	currentpicture:= TurnRight(NeutralMan);
endchar;

beginchar(Knight+Neutral+OnWhite+UpSideDown, qs#, qs#, 0);
	"Neutral knight turned upsidedown on white field";
	currentpicture:= TurnUpSideDown(NeutralMan);
endchar;

%===========================================================

beginchar(Knight+Neutral+OnBlack, qs#, qs#, 0);
	"Neutral knight on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - OuterShape;
	cullit;
	currentpicture:= currentpicture + NeutralMan;
endchar;

beginchar(Knight+Neutral+OnBlack+LeftTurned, qs#, qs#, 0);
	"Neutral knight turned to the left on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnLeft(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnLeft(NeutralMan);
endchar;

beginchar(Knight+Neutral+OnBlack+RightTurned, qs#, qs#, 0);
	"Neutral knight turned to the right on black field";
	MakeBlackField;
	currentpicture:= currentpicture - TurnRight(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnRight(NeutralMan);
endchar;

beginchar(Knight+Neutral+OnBlack+UpSideDown, qs#, qs#, 0);
	"Neutral knight turned upsidedown on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnUpSideDown(NeutralMan);
endchar;

%===========================================================

beginchar(Knight+Black+OnWhite, qs#, qs#, 0);
	"Black knight on white field";
	currentpicture:= BlackMan;
endchar;

beginchar(Knight+Black+OnWhite+LeftTurned, qs#, qs#, 0);
	"Black knight turned to the left on white field";
	currentpicture:= TurnLeft(BlackMan);
endchar;

beginchar(Knight+Black+OnWhite+RightTurned, qs#, qs#, 0);
	"Black knight turned to the right on white field";
	currentpicture:= TurnRight(BlackMan);
endchar;

beginchar(Knight+Black+OnWhite+UpSideDown, qs#, qs#, 0);
	"Black knight turned upsidedown on white field";
	currentpicture:= TurnUpSideDown(BlackMan);
endchar;

%===========================================================

beginchar(Knight+Black+OnBlack, qs#, qs#, 0);
	"Black knight on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - OuterShape;
	cullit;
	currentpicture:= currentpicture + BlackMan;
endchar;

beginchar(Knight+Black+OnBlack+LeftTurned, qs#, qs#, 0);
	"Black knight turned to the left on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnLeft(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnLeft(BlackMan);
endchar;

beginchar(Knight+Black+OnBlack+RightTurned, qs#, qs#, 0);
	"Black knight turned to the right on black field";
	MakeBlackField;
	currentpicture:= currentpicture - TurnRight(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnRight(BlackMan);
endchar;

beginchar(Knight+Black+OnBlack+UpSideDown, qs#, qs#, 0);
	"Black knight turned upsidedown on black field";
	MakeBlackField;
	cullit;
	currentpicture:= currentpicture - TurnUpSideDown(OuterShape);
	cullit;
	currentpicture:= currentpicture + TurnUpSideDown(BlackMan);
endchar;
fi;

%