I recently came across a short discussion of the Schwenk dice and thought it would be fun to create the dice with TikZ
. I found neat tizpictures for up to 9 dots and adapted the code to 16 dots. I did it without thinking (see below), but as I was typing (fast) it became clear that the code was ugly and the faces were not that pretty either.
Any suggestions on how to make more general code for faces with large numbers of dots and pleasant symmetries? That is, loops and looks.
The red faces are the ones copied from Andrew Swann's code linked above. The blue faces were copied from some domino designs I had at home. The green faces were made up on the spot.
\documentclass{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{shapes}
\tikzset{%
dot hidden/.style={},
line hidden/.style={},
dot colour/.style={dot hidden/.append style={color=#1}},
dot colour/.default=black,
line colour/.style={line hidden/.append style={color=#1}},
line colour/.default=black,
}%
\usepackage{xparse}
\NewDocumentCommand{\drawdie}{O{}m}{%
\begin{tikzpicture}[x=1cm,y=1cm,radius=0.06,#1]
\draw[rounded corners=1,line hidden] (0,0) rectangle (1,1);
\ifnum#2<10% "standard die"
\ifodd#2
\fill[dot hidden] (0.5,0.5) circle;% 1,3,5,7,9
\fi
\ifnum#2>1
\fill[dot hidden] (0.15,0.15) circle;% 2
\fill[dot hidden] (0.85,0.85) circle;% 3
\ifnum#2>3
\fill[dot hidden] (0.15,0.85) circle;% 4
\fill[dot hidden] (0.85,0.15) circle;% 5
\ifnum#2>5
\fill[dot hidden] (0.85,0.5) circle;% 5
\fill[dot hidden] (0.15,0.5) circle;% 6
\ifnum#2>7
\fill[dot hidden] (0.5,0.85) circle;% 7
\fill[dot hidden] (0.5,0.15) circle;% 8
\fi
\fi
\fi
\fi
\fi
\ifnum#2>9% "extended die"
\ifnum#2<13%
\fill[dot hidden] (0.15,0.15) circle;
\fill[dot hidden] (0.15,0.85) circle;
\fill[dot hidden] (0.85,0.15) circle;
\fill[dot hidden] (0.85,0.85) circle;
\fill[dot hidden] (0.15,0.38) circle;
\fill[dot hidden] (0.15,0.61) circle;
\fill[dot hidden] (0.85,0.38) circle;
\fill[dot hidden] (0.85,0.61) circle;
\ifodd#2
\fill[dot hidden] (0.50,0.50) circle;
\fill[dot hidden] (0.50,0.15) circle;
\fill[dot hidden] (0.50,0.85) circle;
\else
\fill[dot hidden] (0.50,0.38) circle;
\fill[dot hidden] (0.50,0.61) circle;
\fi
\ifnum#2>11
\fill[dot hidden] (0.50,0.15) circle;
\fill[dot hidden] (0.50,0.85) circle;
\fi
\else
\fill[dot hidden] (0.15,0.15) circle;
\fill[dot hidden] (0.15,0.85) circle;
\fill[dot hidden] (0.85,0.15) circle;
\fill[dot hidden] (0.85,0.85) circle;
\fill[dot hidden] (0.15,0.38) circle;
\fill[dot hidden] (0.15,0.61) circle;
\fill[dot hidden] (0.85,0.38) circle;
\fill[dot hidden] (0.85,0.61) circle;
\fill[dot hidden] (0.38,0.15) circle;
\fill[dot hidden] (0.38,0.85) circle;
\fill[dot hidden] (0.61,0.15) circle;
\fill[dot hidden] (0.61,0.85) circle;
\ifnum#2<14
\fill[dot hidden] (0.50,0.50) circle;
\fi
\ifnum#2>13
\fill[dot hidden] (0.38,0.38) circle;
\fill[dot hidden] (0.61,0.61) circle;
\ifnum#2>14
\fill[dot hidden] (0.38,0.61) circle;
\ifnum#2>15
\fill[dot hidden] (0.61,0.38) circle;
\fi
\fi
\fi
\fi
\fi
\end{tikzpicture}%
}%
\newcommand{\dieA}[1]{%
\drawdie[color=black, line hidden/.append style={fill=red!70}]{#1}}
\newcommand{\dieB}[1]{%
\drawdie[color=black, line hidden/.append style={fill=blue!50}]{#1}}
\newcommand{\dieC}[1]{%
\drawdie[color=black, line hidden/.append style={fill=green!50}]{#1}}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,nodes={rectangle,align=center}]{%
\dieA{1} & \dieA{2} & \dieA{3} & \dieA{4} \\
\dieA{5} & \dieA{6} & \dieA{7} & \dieA{8} \\
\dieA{9} & \dieB{10} & \dieB{11} & \dieB{12} \\
\dieC{13} & \dieC{14} & \dieC{15} & \dieC{16} \\
};
\end{tikzpicture}
\end{document}