Skip to content

Instantly share code, notes, and snippets.

@rocx
Last active April 20, 2020 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocx/81d39d6f2b8b064710c94faf09af8097 to your computer and use it in GitHub Desktop.
Save rocx/81d39d6f2b8b064710c94faf09af8097 to your computer and use it in GitHub Desktop.
Precomputed sheet of 500 die rolls
% Local Variables:
% mode: latex
% TeX-engine: xetex
% fill-column: 64
% End:
\documentclass[12pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%
% The Sheet of Die Rolls %
%%%%%%%%%%%%%%%%%%%%%%%%%%
% By Box O'Rocks <https://rocx.rocks>
% This document is licensed under the Creative Commons Zero license.
% https://creativecommons.org/publicdomain/zero/1.0/
% No warranty is provided, yadda yadda blah blah.
% For all intents and purposes, this was a rather interesting
% exercise in LaTeX and TiKz.
% To compute another sheet of numbers, simply rebuild the PDF.
% Every minute (unfortunately not every second) will yield a new
% batch of die rolls due to random number seeding and the lack of
% granularity of time-fetching in LaTeX.
% "Minutes since midnight as \time" is the closest we're getting
% and the default seed is that multiplied by the current year.
% Packages required:
% * geometry (margins and page dimensions)
% * etoolbox (\ifnumequal for branching what to do for each die type)
% * tikz (outlines, random number generation)
% This is your place to change the dice.
% Valid values: 4, 6, 8, 10, 12, 20
% eg. "3d6" means setting \sides to 6, printing it, and
% scratching off three squares and using their sum.
% eg. "1d100" needs a d10 sheet, use the first diamond as the
% tens digit and the second diamond as the ones digit.
% Treat 0 and 0 as 100.
\newcommand{\sides}{20}
% Customize the look of the numerals.
\newcommand{\dieface}{\bfseries\sffamily}
% The width of the shapes will at least *try* to match the
% largest number available.
% The d10's 0-9 range remains the exception as half of this size.
\newlength{\facewidth}
\settowidth{\facewidth}{\dieface\sides}
\usepackage[width=7in,height=10in,paper=letterpaper]{geometry}
\usepackage{etoolbox}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\renewcommand{\familydefault}{\sfdefault}
\pagenumbering{gobble}
\begin{document}
\setlength\parindent{0pt}
\begin{center}
{\Large\itshape d\sides{} Rolls}
\paragraph*{Directions:}
Substitute this sheet for rolling a \sides{}-sided die.
As each roll is selected, mark it as used.
\vspace{8pt}
\begin{tikzpicture}
\tikzset{
hex/.style={
regular polygon,
regular polygon sides=6,
text width=\facewidth,
shape border rotate=30,
inner sep=0pt,
align=center,
node font=\dieface,
draw
},
cube/.style={
regular polygon,
regular polygon sides=4,
text width=\facewidth,
inner sep=1pt,
align=center,
node font=\dieface,
draw
},
diamond/.style={
regular polygon,
regular polygon sides=4,
text width=\facewidth,
shape border rotate=45,
inner sep=0.5pt,
align=center,
node font=\dieface,
draw
},
diamond10/.style={ % d10-specific
kite,
text width=0.5*\facewidth,
shape border rotate=180,
inner sep=1.5pt,
align=center,
node font=\dieface,
draw
},
triangle/.style={
regular polygon,
regular polygon sides=3,
text width=\facewidth,
inner sep=0pt,
align=center,
node font=\dieface,
draw
},
pentagon/.style={
regular polygon,
regular polygon sides=5,
text width=\facewidth,
shape border rotate=108,
inner sep=0pt,
align=center,
node font=\dieface,
draw
}
}
\ifnumequal{\sides}{4}{
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[triangle] at (\i*0.9,\j*0.9) {\pgfmathrandom{\sides}\pgfmathresult};
}}
}{}
\ifnumequal{\sides}{6}{
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[cube] at (\i*0.85,\j*0.85) {\pgfmathrandom{\sides}\pgfmathresult};
}}
}{}
\ifnumequal{\sides}{8}{
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[diamond] at (\i*0.85,\j*0.9) {\pgfmathrandom{\sides}\pgfmathresult};
}}
}{}
\ifnumequal{\sides}{10}{
% 10-sided dice still look like diamonds from the side.
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[diamond10] at (\i*0.85,\j*0.9) {\pgfmathrandom{0,9}\pgfmathresult};
}}
}{}
\ifnumequal{\sides}{12}{
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[pentagon] at (\i*0.9,\j*0.9) {\pgfmathrandom{\sides}\pgfmathresult};
}}
}{}
\ifnumequal{\sides}{20}{
\foreach \i in {1,...,20}{
\foreach \j in {1,...,25}{
\node[hex] at (\i*0.9,\j*0.9) {\pgfmathrandom{\sides}\pgfmathresult};
}}
}{}
\end{tikzpicture}
\end{center}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment