File: goboards.ldf

package info (click to toggle)
3dldf 2.0.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,508 kB
  • ctags: 7
  • sloc: makefile: 892; sh: 117; cpp: 5
file content (361 lines) | stat: -rw-r--r-- 8,298 bytes parent folder | download | duplicates (2)
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
%%%% goboards.ldf
%%%% Created by Laurence D. Finston (LDF) Wed Oct  5 15:27:12 CEST 2011


%% * (1) Copyright and License.

%%%% This file is part of GNU 3DLDF, a package for three-dimensional drawing.  
%%%% Copyright (C) 2011, 2012, 2013 The Free Software Foundation  

%%%% GNU 3DLDF 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 3 of the License, or 
%%%% (at your option) any later version.  

%%%% GNU 3DLDF 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 GNU 3DLDF; if not, write to the Free Software 
%%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 

%%%% GNU 3DLDF is a GNU package.  
%%%% It is part of the GNU Project of the  
%%%% Free Software Foundation 
%%%% and is published under the GNU General Public License. 
%%%% See the website http://www.gnu.org 
%%%% for more information.   
%%%% GNU 3DLDF is available for downloading from 
%%%% http://www.gnu.org/software/3dldf/LDF.html.

%%%% Please send bug reports to Laurence.Finston@gmx.de
%%%% The mailing list help-3dldf@gnu.org is available for people to 
%%%% ask other users for help.  
%%%% The mailing list info-3dldf@gnu.org is for sending 
%%%% announcements to users. To subscribe to these mailing lists, send an 
%%%% email with ``subscribe <email-address>'' as the subject.  

%%%% The author can be contacted at: 

%%%% Laurence D. Finston 
%%%% c/o Free Software Foundation, Inc. 
%%%% 51 Franklin St, Fifth Floor 
%%%% Boston, MA  02110-1301  
%%%% USA

%%%% Laurence.Finston@gmx.de
 


%% Created:  October 5, 2011
%% Last updated:  October 9, 2011

%% Run like this:

%% 3dldf goboards.ldf 
%% mpost goboards.mp 
%% tex goboards.txt 
%% dvips -o goboards.ps goboards.dvi
%% ps2pdf goboards.ps

%% All on one line:
if false:
3dldf goboards.ldf && mpost goboards.mp && tex goboards.txt && \
dvips -o goboards.ps goboards.dvi \
&& ps2pdf goboards.ps
fi;

%% View the PostScript file using Ghostview like this:
%% gv goboards.ps &
%% or with GNU Ghostview like this:
%% ggv goboards.ps &

%% View the PDF file with Acrobat Reader like this:
%% acroread goboards.pdf &

%% * (1) Beginning of 3DLDF code.

%% ** (2) 

verbatim_metapost "verbatimtex \font\large=cmr12 \font\largeit=cmti12 etex;";

%% *** (3) Declarations and initializations

point p[];
path q[];

rectangle r[];

transform t[];

pen normal_pen;
pen thin_pen;
pen line_pen;
pen dot_pen;

normal_pen := pencircle scaled (.5mm, .5mm, .5mm);

thin_pen := pencircle scaled (.25mm, .25mm, .25mm);

line_pen := pencircle scaled (.333mm, .333mm, .333mm);

dot_pen := pencircle scaled (1.5mm, 1.5mm, 1.5mm);

pickup line_pen;

color_vector cv;

cv += blue;
cv += red;
cv += green;
cv += cyan;
cv += magenta;
cv += yellow;
cv += violet;
cv += orange;
cv += blue;
cv += red;
cv += green;
cv += cyan;
cv += magenta;
cv += yellow;
cv += violet;
cv += orange;
cv += blue;
cv += red;
cv += green;
cv += cyan;
cv += magenta;
cv += yellow;
cv += violet;
cv += orange;


picture v[];

bool_point_vector bpv;

string s;

%% *** (3) Macros

%% **** (4)

def go_board (Q, V, v_unit_size) {numeric h_unit_size, numeric line_ctr} = 

%% ***** (5)

   string S;

   rectangle R[];
   transform T[];
   point P[];

   v_unit_size := h_unit_size * 14 / 15;

   R0 := unitsquare scaled (h_unit_size, 0, v_unit_size) rotated (90, 0);
   R1 := R0;
   R2 := R0;

   R3 := (unitsquare scaled ((line_ctr - 1) * h_unit_size + 1.25 * h_unit_size, 
          0, (line_ctr - 1) * v_unit_size + 1.25 * v_unit_size) 
         rotated (90, 0)) 
         shifted ((line_ctr - 2) / 2 * h_unit_size, -(line_ctr - 2) / 2 * v_unit_size);

   draw R3 on_picture V;  %% Outline around board

   T0 := identity shifted (h_unit_size, 0);
   T1 := identity shifted (0, -v_unit_size);

   for j = 0 upto (line_ctr - 2):
      R2 := R1;
      for i = 0 upto (line_ctr - 2):
         Q[j][i] := get_point 3 R2;
         draw R2 on_picture V;
         R2 *= T0;
      endfor;
      Q[j][line_ctr - 1] := get_point 2 R2 transformed inverse T0;
      R1 *= T1;
   endfor;

   R2 := R1 transformed (inverse T1);

   for i = 0 upto (line_ctr - 2):
      Q[line_ctr - 1][i] := get_point 0 R2;
      R2 *= T0;
   endfor;

   R2 *= inverse T0;

   Q[line_ctr - 1][line_ctr - 1] := get_point 1 R2;

   for i = 0 upto 3:
      P[i] := get_point (i) R0;
   endfor;

   pickup dot_pen;

   drawdot(2.5 * h_unit_size, -2.5 * v_unit_size) on_picture V;

   drawdot((line_ctr - 4.5) * h_unit_size, -(line_ctr - 4.5) * v_unit_size) on_picture V;

   drawdot(2.5 * h_unit_size, -(line_ctr - 4.5) * v_unit_size) on_picture V;

   drawdot((line_ctr - 4.5) * h_unit_size, -2.5 * v_unit_size) on_picture V;

   drawdot((line_ctr - 10.5) * h_unit_size, -(line_ctr - 10.5) * v_unit_size) on_picture V;

   drawdot(2.5 * h_unit_size, -(line_ctr - 10.5) * v_unit_size) on_picture V;

   drawdot((line_ctr - 10.5) * h_unit_size, -2.5 * v_unit_size) on_picture V;

   drawdot((line_ctr - 4.5) * h_unit_size, -(line_ctr - 10.5) * v_unit_size) on_picture V;

   drawdot((line_ctr - 10.5) * h_unit_size, -(line_ctr - 4.5) * v_unit_size) on_picture V;

   P4 := P3 shifted (0, .75v_unit_size);

   P5 := P3 shifted (0, -(line_ctr - 0.375) v_unit_size);

   %dotlabel.bot("$P_{5}$", P5) V;   

   numeric N;

   N := 65;

   pickup line_pen;

   verbatim_metapost "verbatimtex \setbox0=\hbox{\large Q\/} \setbox1=\hbox{\large M} etex;"; 

   for i = 1 upto line_ctr:
      S := "\hbox{\vbox to \ht0{\hbox to \wd1{\hfil\large\char" & decimal N & "\hfil}\vfil}}";
      label.top(S, P4) V;
      label.bot(S, P5) V;
      P5 *= P4 *= T0;
      N += 1;
      if N == 73:
         N += 1;
      fi;
   endfor;

   P6 := P3 shifted (-.625 h_unit_size);
   P7 := P3 shifted ((line_ctr - 0.375) h_unit_size);

   verbatim_metapost "verbatimtex \setbox0=\hbox{\large 00} etex;"; 

   for i = line_ctr downto 1:
      S := "\hbox{\vbox to \ht0{\hbox to \wd0{\hfil\large " & decimal i & "\hfil}\vfil}}";
      label.lft(S, P6) V;
      label.rt(S, P7) V;
      P6 *= P7 *= T1;
   endfor;

%   dotlabel.bot("$P_{6}$", P6) V;   


%% ***** (5)

enddef;


%% *** (3) Figure 0

beginfig(0); 

   picture Z;

   h_unit_size := .625cm;
   numeric v_unit_size;

   numeric line_ctr;

   line_ctr := 19;

   point m[][];

   go_board (m, Z, v_unit_size) {h_unit_size, line_ctr};

   v0 := Z;

   clear Z;

   h_unit_size := .575cm;

   point n[][];

   go_board (n, Z, v_unit_size) {h_unit_size, 13};

   v2 := Z;

endfig with_projection parallel_x_y no_sort;

%% *** (3) Figure 1

beginfig(1);  

   current_picture += v0;

   if false: % true
   for i = 0 upto 18:
      for j = 0 upto 18:
%        show m[i][j];
         drawdot m[i][j] withpen dot_pen with_color cv[j];
      endfor;
   endfor;
   fi;

   v1 := v0;

   shift v1 (0, -20 * v_unit_size - 2cm) ;

   current_picture += v1;

endfig with_projection parallel_x_y no_sort;


%% *** (3) Figure 2

beginfig(2);  

   current_picture += v2;

   v3 := v2;

   shift v3 (15 * h_unit_size + 1cm, 0);

   current_picture += v3;

endfig with_projection parallel_x_y no_sort;


%% *** (3)

%% *** (3) End of 3DLDF code

verbatim_metapost "end;";

end;

%% ** (2) 

%% * (1) Emacs-Lisp code for use in indirect buffers when using the          
%%       GNU Emacs editor.  The local variable list is not evaluated when an 
%%       indirect buffer is visited, so it's necessary to evaluate the       
%%       following s-expression in order to use the facilities normally      
%%       accessed via the local variables list.                              
%%       \initials{LDF 2004.02.12}.                                          

%% (progn (metafont-mode) (outline-minor-mode t) (setq fill-column 80) (ignore '(  
%% )) (setq outline-regexp "%% [*\f]+"))

%% * (1) Local variables for Emacs.

%% Local Variables:
%% mode:Metafont
%% eval:(outline-minor-mode t)
%% eval:(read-abbrev-file abbrev-file-name)
%% outline-regexp:"%% [*\f]+"
%% End: