Debian Codegraph @

texmf-dist/fonts/source/public/chess/chessdiag.mf

raw
1 % This is `chessdiag.mf' version 1.1 as of 11/90
2 % METAfounded by Piet Tutelaers (internet: [email protected])
3
4 % file generates a complete chess diagram
5
6 % most versions of METAFONT have memorylimits so generating a complete
7 % diagram of 160 X 160 points for a 300 DPI printer is not possible
8
9 mode_setup;
10 input chessbase;
11
12 def draw_pieces(text piece_list) =
13 string piece, location;
14 for p=piece_list:
15 l:=length p;
16 exitunless (l=2) or (l=3);
17 if l=2: piece:="p"; i:=0;
18 else: piece:=substring(0,1) of p; i:=1; fi;
19 column:=ASCII substring(i,i+1) of p - ASCII "a";
20 row:=ASCII substring(i+1,i+2) of p - ASCII "1";
21 if not odd(column+row): background:=dark; else: background:=light; fi;
22 scantokens piece(d, column,row);
23 endfor;
24 enddef;
25
26 def w(text piece_list) =
27 color:=white;
28 empty_board(d); draw_pieces(piece_list);
29 enddef;
30
31 def b(text piece_list) =
32 color:=black;
33 draw_pieces(piece_list);
34 enddef;
35
36 M=8; % number of squares
37 d#:=100pt#/M; % size per square
38 fine#:=1/100*d#; thin#:=1/90*d#; thick#:=1/36*d#; border#:=1/20*d#;
39 define_blacker_pixels(fine, thin, thick, border);
40 define_whole_pixels(d);
41 pickup pencircle scaled fine; fine_pen:=savepen ; % for drawing dark squares
42 pickup pencircle scaled border; border_pen:=savepen ; % for border ofboard
43 pickup pencircle scaled thin; thin_pen:=savepen ; % for drawing pieces
44 pickup pencircle scaled thick; thick_pen:=savepen; % for drawing inside pieces
45 light=0; dark=1; white=0; black=1;
46
47 % put here the wanted diagram (ex.: mate in three problem)
48
49 w("Kc2","Nb4","Bf8","b3","g7");
50 b("Ka3","b6");
51 showit;
52
53 message("White mates in three moves. Do you see how?");
54 StopMe;
55
56 end;