Debian Codegraph @

texmf-dist/source/latex/wargame/chit/stack.dtx

raw
1 % \iffalse
2 % <*chit>
3 % --------------------------------------------------------------------
4 % \fi
5 % \subsubsection{Stacking of chits}
6 %
7 % Stacking of chits. The key \spec{chit/stack direction} sets the
8 % default direction to make the stack in.
9 %
10 % \begin{macrocode}
11 % offset, location, direction, list
12 \tikzset{%
13 chit/stack direction/.store in=\chit@stack@dir,
14 chit/stack direction/.initial={(.3,.3)},
15 }
16 % \end{macrocode}
17 %
18 % Now the code
19 %
20 % \begin{macrocode}
21 \def\chit@stack@dir{(.3,.3)}
22 \def\stackchits(#1){%
23 \@ifnextchar({\st@ckchits{#1}}{\st@ckchits{#1}(.3,.3)}%)
24 }
25 \def\st@ckchits#1(#2)#3{%
26 \chit@dbg{2}{Stacking chits `#1', `#2', `#3'}%
27 \edef\xy{#1}%
28 \chit@dbg{4}{Stack start at \xy}%
29 \foreach[count=\i from 0] \c/\o in {#3} {%
30 \ifx\c\empty\else%
31 \edef\ccc{\c}%
32 \chit@dbg{2}{Adding \meaning\ccc\space to stack at (\xy)' `\o'}%
33 \expandafter\ccc(\xy)%
34 %%
35 \ifx\c\o\else%
36 %\chit@dbg{0}{Option: \o}
37 \edef\ccc{\o}%
38 \expandafter\ccc(\xy)%
39 \fi
40 \expandafter\ccc(\xy)%
41 \tikzmath{%
42 coordinate \cc;%
43 \cc = (\xy) + (#2);}
44 \xdef\xy{\cc}%
45 \fi%
46 }%
47 \@ifnextchar;{\@gobble}{}%
48 }
49 % \end{macrocode}
50 %
51 % \iffalse
52 % </chit>
53 % --------------------------------------------------------------------
54 % \fi