%%%% goboards.ldf %%%% Created by Laurence D. Finston (LDF) Wed Oct 5 15:27:12 CEST 2011 %%%% $Id: goboards.ldf,v 1.9 2022/12/16 14:05:05 lfinsto1 Exp $ %% * (1) Copyright and License. %%%% This file is part of GNU 3DLDF, a package for three-dimensional drawing. %%%% Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 The Free Software Foundation, Inc. %%%% 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 '' 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: