diff options
Diffstat (limited to 'macros/latex/contrib/wargame/source/chit/dice.dtx')
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/dice.dtx | 286 |
1 files changed, 286 insertions, 0 deletions
diff --git a/macros/latex/contrib/wargame/source/chit/dice.dtx b/macros/latex/contrib/wargame/source/chit/dice.dtx new file mode 100644 index 0000000000..0c07c91d4f --- /dev/null +++ b/macros/latex/contrib/wargame/source/chit/dice.dtx @@ -0,0 +1,286 @@ +% \iffalse +% <*chit> +% -------------------------------------------------------------------- +% \fi +% \subsubsection{Dice} +% +% First, a regular 6-sided dice with configurable number of dots. Use +% like +% +% \begin{Syntax} +% \cs{pic}\oarg{pic options}\{dice=\meta{eyes}\} +% \end{Syntax} +% +% For example: +% +% \begin{enumerate} +% \item \tikz{\pic[transform shape]{dice=1};} +% \item \tikz{\pic[transform shape]{dice=2};} +% \item \tikz{\pic[transform shape]{dice=3};} +% \item \tikz{\pic[transform shape]{dice=4};} +% \item \tikz{\pic[transform shape]{dice=5};} +% \item \tikz{\pic[transform shape]{dice=6};} +% \end{enumerate} +% +% \begin{macrocode} +\tikzset{ + dice bg/.style={ + % /utils/exec={ + % \pgfgettransformentries{% + % \wg@jaca}{% + % \wg@jacb}{% + % \wg@jacc}{% + % \wg@jacd}{% + % \wg@tmp}{% + % \wg@tmp}% + % \pgfmathsetmacro{\wg@tmp}{% + % sqrt(abs(\wg@jaca*\wg@jacd-\wg@jacb*\wg@jacc))} + % \xdef\wg@tmp{\wg@tmp}},% + fill=black, + draw=none, + minimum width=1cm, + minimum height=1cm, + scale rounded corners, + rounded corners=.1cm, + inner sep=0pt, + transform shape}, + dice fg/.style={ + fill=white, + shape=circle, + inner sep=0pt, + minimum size=.2cm, + transform shape}, + pics/dice/.style={ + code={ + \node[dice bg] (dice bg) {}; + \ifodd#1\node[dice fg] at (dice bg) {};\fi + \ifnum#1>1% + \node[dice fg] at ($(dice bg)+(-45:.4)$){};% + \node[dice fg] at ($(dice bg)+(135:.4)$){};% + \fi% + \ifnum#1>3% + \node[dice fg] at ($(dice bg)+( 45:.4)$){};% + \node[dice fg] at ($(dice bg)+(-135:.4)$){};% + \fi% + \ifnum#1=6% + \node[dice fg] at ($(dice bg)+(-.282,0)$){}; + \node[dice fg] at ($(dice bg)+( .282,0)$){}; + \fi + } + }, + pics/dice/.default=3 +} +\newcommand\dicemark[2][scale=.5]{% + \tikz[baseline={($(dice bg.south east)!.25!(dice bg.north east)$)},#1]{ + \pic[transform shape]{dice=3};}} +% \end{macrocode} +% +% Now some shapes of different dice. This was originally done by +% \href{https://tex.stackexchange.com/questions/144193/how-do-i-put-a-die-roll-at-the-top-of-each-page#answer-144474}{David +% Carlisle}. Usage is for example +% +% \begin{Syntax} +% \cs{node}[shape=\meta{dice},\meta{node options}] \marg{value}; +% \end{Syntax} +% +% where \meta{dice} is one of \texttt{d4}, \texttt{d6}, \texttt{d8}, +% \texttt{d10}, \texttt{d12}, or \texttt{d20}. +% +% \def\DiceExample#1{% +% \begin{tikzpicture}[ +% die/.style={ +% shape=#1, +% scale line widths, +% line width=1pt, +% transform shape, +% scale=.7 +% }, +% fg die/.style={ +% die, +% fill=##1, +% draw=gray!25!white, +% text=white}, +% die shadow/.style={ +% die, +% fill=black, +% draw=none, +% opacity=.5}] +% \node[die shadow,rotate=10] at (.20,.07){}; +% \node[fg die=red,rotate=10] at (.15,.10){}; +% \node[die shadow,rotate=-10] at (-.08,-.11){}; +% \node[fg die=blue,rotate=-10] at (-.15,-.1){}; +% \draw(-.5,-.5)rectangle(.6,.5); +% \end{tikzpicture} +% } +% +% \paragraph{Tetrahedron} +% +% \DiceExample{d4} +% +% \begin{macrocode} +\pgfdeclareshape{d4}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ + % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathmoveto{\pgfpoint{0cm}{.4cm}} + \pgfpathlineto{\pgfpoint{.433cm}{-.35cm}} + \pgfpathlineto{\pgfpoint{-.433cm}{-.35cm}} + \pgfpathlineto{\pgfpoint{0cm}{.4cm}} + % \pgfusepath{draw} %draw border + % \pgfusepath{draw} %draw rectangle + }} +% \end{macrocode} +% +% \paragraph{Cubic} +% +% \DiceExample{d6} +% +% \begin{macrocode} +\pgfdeclareshape{d6}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ + % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathrectanglecorners{\pgfpoint{.4cm}{.4cm}}{\pgfpoint{-.4cm}{-.4cm}} + % \pgfusepath{draw} %draw rectangle + }} +% \end{macrocode} +% +% \paragraph{Octahedron} +% +% \DiceExample{d8} +% +% \begin{macrocode} +\pgfdeclareshape{d8}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ + % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathmoveto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{.433cm}{.25cm}} + \pgfpathlineto{\pgfpoint{.433cm}{-.25cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{-.433cm}{-.25cm}} + \pgfpathlineto{\pgfpoint{-.433cm}{.25cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{.433cm}{-.25cm}} + \pgfpathlineto{\pgfpoint{-.433cm}{-.25cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + % \pgfusepath{draw} %draw interiaor + }} +% \end{macrocode} +% +% \paragraph{Decahedron} +% +% \DiceExample{d10} +% +% \begin{macrocode} +\pgfdeclareshape{d10}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ + % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathmoveto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{.294cm}{-.154cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.3cm}} + \pgfpathlineto{\pgfpoint{-.294cm}{-.154cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{.475cm}{.1cm}} + \pgfpathlineto{\pgfpoint{.475cm}{-.1cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{-.475cm}{-.1cm}} + \pgfpathlineto{\pgfpoint{-.475cm}{.1cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + \pgfpathmoveto{\pgfpoint{.294cm}{-.154cm}} + \pgfpathlineto{\pgfpoint{.475cm}{-.1cm}} + \pgfpathmoveto{\pgfpoint{-.475cm}{-.1cm}} + \pgfpathlineto{\pgfpoint{-.294cm}{-.154cm}} + \pgfpathmoveto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.3cm}} + % \pgfusepath{draw} %draw interiaor + }} +% \end{macrocode} +% +% \paragraph{Dodecahedron} +% +% \DiceExample{d12} +% +% \begin{macrocode} +\pgfdeclareshape{d12}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathmoveto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{0.294cm}{.405cm}} + \pgfpathlineto{\pgfpoint{.475cm}{.173cm}} + \pgfpathlineto{\pgfpoint{.475cm}{-.173cm}} + \pgfpathlineto{\pgfpoint{.294cm}{-.405cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{-.294cm}{-.405cm}} + \pgfpathlineto{\pgfpoint{-.475cm}{-.173cm}} + \pgfpathlineto{\pgfpoint{-.475cm}{.173cm}} + \pgfpathlineto{\pgfpoint{-.294cm}{.405cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{0cm}{.349cm}} + \pgfpathlineto{\pgfpoint{.332cm}{.108cm}} + \pgfpathlineto{\pgfpoint{.205cm}{-.282cm}} + \pgfpathlineto{\pgfpoint{-.205cm}{-.282cm}} + \pgfpathlineto{\pgfpoint{-.332cm}{.108cm}} + \pgfpathlineto{\pgfpoint{0cm}{.349cm}} + \pgfpathmoveto{\pgfpoint{.475cm}{.173cm}} + \pgfpathlineto{\pgfpoint{.332cm}{.108cm}} + \pgfpathmoveto{\pgfpoint{.294cm}{-.405cm}} + \pgfpathlineto{\pgfpoint{.205cm}{-.282cm}} + \pgfpathmoveto{\pgfpoint{-.294cm}{-.405cm}} + \pgfpathlineto{\pgfpoint{-.205cm}{-.282cm}} + \pgfpathmoveto{\pgfpoint{-.475cm}{.173cm}} + \pgfpathlineto{\pgfpoint{-.332cm}{.108cm}} + % \pgfusepath{draw} %draw interiaor + }} +% \end{macrocode} +% +% \paragraph{Icosohedron} +% +% \DiceExample{d20} +% +% \begin{macrocode} +\pgfdeclareshape{d20}{ + \anchor{center}{\pgfpointorigin} % within the node, (0,0) is the center + \anchor{text}{ % this is used to center the text in the node + \pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}} + \backgroundpath{ % draw border + \pgfpathmoveto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{.454cm}{.262cm}} + \pgfpathlineto{\pgfpoint{.454cm}{-.262cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{-.454cm}{-.262cm}} + \pgfpathlineto{\pgfpoint{-.454cm}{.262cm}} + \pgfpathlineto{\pgfpoint{0cm}{.5cm}} + \pgfpathlineto{\pgfpoint{0cm}{.292cm}} + \pgfpathlineto{\pgfpoint{.253cm}{-.146cm}} + \pgfpathlineto{\pgfpoint{-.253cm}{-.146cm}} + \pgfpathlineto{\pgfpoint{0cm}{.292cm}} + \pgfpathlineto{\pgfpoint{.454cm}{.262cm}} + \pgfpathlineto{\pgfpoint{.253cm}{-.146cm}} + \pgfpathlineto{\pgfpoint{0cm}{-.5cm}} + \pgfpathlineto{\pgfpoint{-.253cm}{-.146cm}} + \pgfpathlineto{\pgfpoint{-.454cm}{.262cm}} + \pgfpathlineto{\pgfpoint{0cm}{.292cm}} + \pgfpathmoveto{\pgfpoint{.454cm}{-.262cm}} + \pgfpathlineto{\pgfpoint{.253cm}{-.146cm}} + \pgfpathmoveto{\pgfpoint{-.454cm}{-.262cm}} + \pgfpathlineto{\pgfpoint{-.253cm}{-.146cm}} + % \pgfusepath{draw} %draw interiaor + }} +% \end{macrocode} +% +% \iffalse +% </chit> +% -------------------------------------------------------------------- +% \fi |