summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-08 23:10:33 +0000
committerKarl Berry <karl@freefriends.org>2013-02-08 23:10:33 +0000
commitfc6a4f265993210c23ad71afdf82ffcadde81252 (patch)
treebb2e4815c8e74df4e833e930dfc58387543bc518 /Master/texmf-dist/tex/latex
parent872f1c6c598cdf1da901a0a06d09405cacb75268 (diff)
navygame (8feb13)
git-svn-id: svn://tug.org/texlive/trunk@29063 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/navygame/navygame.sty282
1 files changed, 282 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/navygame/navygame.sty b/Master/texmf-dist/tex/latex/navygame/navygame.sty
new file mode 100644
index 00000000000..df613f0297c
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/navygame/navygame.sty
@@ -0,0 +1,282 @@
+%%
+%% Copyright (C) 2013 by:
+%% Josef Kleber
+%% <josef.kleber@gmx.de>
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of LaTeX version
+%% 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "author-maintained".
+%%
+%% The Current Maintainer of this work is Josef Kleber.
+%%
+%% This work consists of all files listed in manifest.txt.
+%%
+%
+\ProvidesPackage{navygame}[2013/02/07 navygame.sty v1.0 - Josef Kleber (C) 2013]%
+%
+\RequirePackage{xkeyval}%
+\RequirePackage{ifthen}%
+\RequirePackage{ragged2e}%
+\RequirePackage{tikz}%
+\RequirePackage{etoolbox}%
+%
+% options
+\newcommand*\NG@width{6cm}%
+\newcommand*\NG@fontsize\Large%
+\newcommand*\NG@rows{5}%
+\newcommand*\NG@columns{5}%
+\newcommand*\NG@scale{1}%
+\newcommand*\NG@shipcolor{green}%
+\newcommand*\NG@SB@indent{0.75cm}%
+\newcommand*\NG@SB@width{5.15cm}%
+\newcommand*\NG@SB@shipboxscale{1}%
+%
+\newcounter{NG@rows}%
+\newcounter{NG@columns}%
+\newcounter{NG@shipH}%
+\newcounter{NG@shipV}%
+%
+\setcounter{NG@rows}{\NG@rows}%
+\setcounter{NG@columns}{\NG@columns}%
+\stepcounter{NG@rows}%
+\stepcounter{NG@columns}%
+%
+\define@key{navygame.sty}{rows}[5]%
+{%
+ \renewcommand*\NG@rows{#1}%
+}%
+%
+\define@key{navygame.sty}{columns}[5]%
+{%
+ \renewcommand*\NG@columns{#1}%
+}%
+%
+\define@key{navygame.sty}{shipcolor}[green]%
+{%
+ \renewcommand*\NG@shipcolor{#1}%
+}%
+%
+\define@key{navygame.sty}{scale}[1]%
+{%
+ \renewcommand*\NG@scale{#1}%
+}%
+%
+\define@choicekey*{navygame.sty}{fontsize}[\NG@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
+{%
+ \ifcase\nr\relax
+ \renewcommand*\NG@fontsize{\tiny}%
+ \or%
+ \renewcommand*\NG@fontsize{\scriptsize}%
+ \or%
+ \renewcommand*\NG@fontsize{\footnotesize}%
+ \or%
+ \renewcommand*\NG@fontsize{\small}%
+ \or%
+ \renewcommand*\NG@fontsize{\normalsize}%
+ \or%
+ \renewcommand*\NG@fontsize{\large}%
+ \or%
+ \renewcommand*\NG@fontsize{\Large}%
+ \or%
+ \renewcommand*\NG@fontsize{\LARGE}%
+ \or%
+ \renewcommand*\NG@fontsize{\huge}%
+ \or%
+ \renewcommand*\NG@fontsize{\Huge}%
+ \fi%
+}%
+%
+\define@key{navygame.sty}{width}[6cm]%
+{%
+ \renewcommand*\NG@width{#1}%
+}%
+%
+\define@key{navygame.sty}{sbindent}[0.75cm]%
+{%
+ \renewcommand*\NG@SB@indent{#1}%
+}%
+%
+\define@key{navygame.sty}{sbwidth}[5.15cm]%
+{%
+ \renewcommand*\NG@SB@width{#1}%
+}%
+%
+\define@key{navygame.sty}{sbshipscale}[1]%
+{%
+ \renewcommand*\NG@SB@shipboxscale{#1}%
+}%
+%
+\define@key{navygame}{rows}%
+{%
+ \renewcommand*\NG@rows{#1}%
+}%
+%
+\define@key{navygame}{columns}%
+{%
+ \renewcommand*\NG@columns{#1}%
+}%
+%
+\define@key{navygame}{shipcolor}%
+{%
+ \renewcommand*\NG@shipcolor{#1}%
+}%
+%
+\define@key{navygame}{scale}%
+{%
+ \renewcommand*\NG@scale{#1}%
+}%
+%
+\define@choicekey*{navygame}{fontsize}[\NG@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
+{%
+ \ifcase\nr\relax
+ \renewcommand*\NG@fontsize{\tiny}%
+ \or%
+ \renewcommand*\NG@fontsize{\scriptsize}%
+ \or%
+ \renewcommand*\NG@fontsize{\footnotesize}%
+ \or%
+ \renewcommand*\NG@fontsize{\small}%
+ \or%
+ \renewcommand*\NG@fontsize{\normalsize}%
+ \or%
+ \renewcommand*\NG@fontsize{\large}%
+ \or%
+ \renewcommand*\NG@fontsize{\Large}%
+ \or%
+ \renewcommand*\NG@fontsize{\LARGE}%
+ \or%
+ \renewcommand*\NG@fontsize{\huge}%
+ \or%
+ \renewcommand*\NG@fontsize{\Huge}%
+ \fi%
+}%
+%
+\define@key{navygame}{width}%
+{%
+ \renewcommand*\NG@width{#1}%
+}%
+%
+\define@key{navygame}{sbindent}%
+{%
+ \renewcommand*\NG@SB@indent{#1}%
+}%
+%
+\define@key{navygame}{sbwidth}%
+{%
+ \renewcommand*\NG@SB@width{#1}%
+}%
+%
+\define@key{navygame}{sbshipscale}%
+{%
+ \renewcommand*\NG@SB@shipboxscale{#1}%
+}%
+%
+\ExecuteOptionsX{rows,columns,width,fontsize,shipcolor,scale,sbindent,sbwidth,sbshipscale}%
+%
+\ProcessOptionsX\relax%
+%
+\newcommand*\NG@Pfive{.5}%
+\gdef\NG@shipbox{}%
+%
+\newcommand*\Ship{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor] (0,0) circle (1);}%
+\newcommand*\ShipC{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}%
+\newcommand*\ShipT{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}%
+\newcommand*\ShipB{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}%
+\newcommand*\ShipL{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
+\newcommand*\ShipR{\tikz[scale=\NG@scale]\draw[scale=.36,fill=\NG@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
+% versions for \shipbox without second scale
+\newcommand*\@Ship{\tikz\draw[scale=.144,fill=\NG@shipcolor] (0,0) circle (1);}%
+\newcommand*\@ShipC{\tikz\draw[scale=.144,fill=\NG@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}%
+\newcommand*\@ShipT{\tikz\draw[scale=.144,fill=\NG@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}%
+\newcommand*\@ShipB{\tikz\draw[scale=.144,fill=\NG@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}%
+\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\NG@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
+\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\NG@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
+%
+\newcommand*\NG@shipparts[3]%
+{%
+ \node at (#1\NG@Pfive,#2\NG@Pfive){\NG@fontsize#3};%
+}%
+%
+\newcommand*\NG@printpartsH[1]%
+{%
+ \stepcounter{NG@shipH}%
+ \NG@shipparts{\arabic{NG@shipH}}{\arabic{NG@shipV}}{#1}%
+}%
+%
+\newcommand*\NG@printpartsV[1]%
+{%
+ \stepcounter{NG@shipV}%
+ \NG@shipparts{\arabic{NG@shipH}}{\arabic{NG@shipV}}{#1}%
+}%
+%
+\newcommand*\NG@printship[1]%
+{%
+ \ifthenelse{\equal{#1}{1}}{\scalebox{\NG@SB@shipboxscale}{\@Ship}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{2}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{3}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{4}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{5}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{6}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{7}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{8}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{9}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+ \ifthenelse{\equal{#1}{10}}{\scalebox{\NG@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
+}%
+%
+\newcommand*\NG@printshipbox[1]%
+{% \expandafters needed because csv list is stored in macro
+ \expandafter\forcsvlist\expandafter\NG@printship\expandafter{#1}
+}%
+%
+\newcommand*\shipH[1]%
+{%
+ \setcounter{NG@shipV}{\value{NG@rows}}%
+ \setcounter{NG@shipH}{0}%
+ \forcsvlist\NG@printpartsH{#1}%
+}%
+%
+\newcommand*\shipV[1]%
+{%
+ \setcounter{NG@shipV}{0}%
+ \setcounter{NG@shipH}{0}%
+ \forcsvlist\NG@printpartsV{#1}%
+}%
+%
+\newcommand*\ship[3]%
+{%
+ \node at (#1\NG@Pfive,#2\NG@Pfive){#3};%
+}%
+%
+\newcommand*\shipbox[2][]%
+{%
+ \setkeys{shipbox}{#1}%
+ \gdef\NG@shipbox{#2}%
+}%
+%
+\newenvironment{navygame}[1][]%
+{%
+ \setkeys{navygame}{#1}%
+ \shipbox{}% clear shipbox
+ \setcounter{NG@rows}{\NG@rows}%
+ \setcounter{NG@columns}{\NG@columns}%
+ \stepcounter{NG@rows}%
+ \stepcounter{NG@columns}%
+ \begin{minipage}[t]{\NG@width}%
+ \begin{tikzpicture}[scale=\NG@scale]%
+ \draw[step=1cm] (1,1) grid (\value{NG@columns},\value{NG@rows});%
+}%
+{%
+ \end{tikzpicture}%
+ \par\hbadness=10000\medskip\noindent\hspace{\NG@SB@indent}\begin{minipage}{\NG@SB@width}{\hbadness=10000\RaggedRight\NG@printshipbox{\NG@shipbox}}\end{minipage}%
+ \end{minipage}
+}%
+%
+\endinput% \ No newline at end of file