summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/wargame/source/hex/shape.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/wargame/source/hex/shape.dtx')
-rw-r--r--macros/latex/contrib/wargame/source/hex/shape.dtx105
1 files changed, 105 insertions, 0 deletions
diff --git a/macros/latex/contrib/wargame/source/hex/shape.dtx b/macros/latex/contrib/wargame/source/hex/shape.dtx
index 0d31da837f..104dbf23c6 100644
--- a/macros/latex/contrib/wargame/source/hex/shape.dtx
+++ b/macros/latex/contrib/wargame/source/hex/shape.dtx
@@ -14,6 +14,77 @@
% such as terrain and so on.
%
% \begin{macrocode}
+\tikzset{%
+ /hex/.cd,
+ bev/.store in=\hex@bevel, bev/.initial=,
+ bevel fraction/.store in=\hex@bevel@frac,bevel fraction/.initial=10,
+ bevel/.is choice,
+ bevel/none/.style = {/hex/bev=},
+ bevel/north west/.style = {/hex/bev=1},
+ bevel/north east/.style = {/hex/bev=2},
+ bevel/south west/.style = {/hex/bev=3},
+ bevel/south east/.style = {/hex/bev=4},
+ bevel/NW/.style = {/hex/bev=1},
+ bevel/NE/.style = {/hex/bev=2},
+ bevel/SW/.style = {/hex/bev=3},
+ bevel/SE/.style = {/hex/bev=4},
+ bevel/.default = {north west},
+}
+\def\hex@bevel@frac{10}
+\tikzset{
+ hex/bevel highlight/.style={fill=white,opacity=.25},
+ hex/bevel shadow/.style={fill=black,opacity=.25},
+}
+% \end{macrocode}
+%
+%
+%
+% \begin{macrocode}
+\newdimen\wg@tmpe
+\newdimen\wg@tmpf
+\newdimen\wg@tmpg
+\def\hex@bevel@path#1{%
+ \scope[#1]
+ \wg@tmpe=\wg@tmpa\multiply\wg@tmpe by \hex@bevel@frac
+ \wg@tmpf=\wg@tmpb\multiply\wg@tmpf by \hex@bevel@frac
+ \wg@tmpg=\wg@tmpc\multiply\wg@tmpg by \hex@bevel@frac
+ \divide\wg@tmpe100
+ \divide\wg@tmpf100
+ \divide\wg@tmpg100
+ % Start
+ \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
+ % Left
+ \pgfpathlineto{\pgfqpoint{-\wg@tmpa}{\wg@tmpb}}%
+ % Left-down
+ \pgfpathlineto{\pgfqpoint{\wg@tmpc}{\wg@tmpd}}%
+ % Right down
+ \wg@tmpa=-\wg@tmpa%
+ \wg@tmpb=-\wg@tmpb%
+ \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
+ % Up, in
+ \advance\wg@tmpa\wg@tmpe%
+ \advance\wg@tmpb\wg@tmpf%
+ \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
+ % Left-down, in
+ \advance\wg@tmpc-\wg@tmpg
+ \pgfpathlineto{\pgfqpoint{\wg@tmpc}{\wg@tmpd}}%
+ % Left, down in
+ \advance\wg@tmpb-\wg@tmpf\wg@tmpb-\wg@tmpb%
+ \advance\wg@tmpb-\wg@tmpf
+ \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
+ % Start, down in
+ \advance\wg@tmpa-\wg@tmpe\wg@tmpa-\wg@tmpa%
+ \advance\wg@tmpa-\wg@tmpe
+ \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
+ % %
+ \pgfclosepath%
+ \pgfusepath{fill}
+ \endscope}%
+% \end{macrocode}
+%
+%
+%
+% \begin{macrocode}
\hex@dbg{5}{Base vertex: \hex@xx,\hex@yy}
\hex@dbg{5}{Base edges: \hex@e@xx,\hex@e@yy}
\pgfdeclareshape{hex/hex}{%
@@ -187,6 +258,40 @@
% \begin{macrocode}
\@ifundefined{hex@label}{\let\hex@label\empty}{}
\ifx\hex@label\empty\else\hex@do@label\fi%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \@ifundefined{hex@bevel}{\let\hex@bevel\empty}{}
+ \ifx\hex@bevel\empty\else%
+ \northeast
+ \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y%
+ \west
+ \wg@tmpc=\pgf@x\wg@tmpd=\pgf@y%
+ \ifcase\hex@bevel\relax
+ \or%1
+ \or\wg@tmpa=-\wg@tmpa\wg@tmpc=-\wg@tmpc%2
+ \or\wg@tmpb=-\wg@tmpb\wg@tmpd=-\wg@tmpd%3
+ \or% 4
+ \wg@tmpa=-\wg@tmpa\wg@tmpc=-\wg@tmpc%
+ \wg@tmpb=-\wg@tmpb\wg@tmpd=-\wg@tmpd%
+ \fi
+ \hex@bevel@path{chit/bevel highlight}
+ \northeast
+ \wg@tmpa=-\pgf@x\wg@tmpb=-\pgf@y%
+ \west
+ \wg@tmpc=-\pgf@x\wg@tmpd=-\pgf@y%
+ \ifcase\hex@bevel\relax
+ \or%1
+ \or\wg@tmpa=-\wg@tmpa\wg@tmpc=-\wg@tmpc%2
+ \or\wg@tmpb=-\wg@tmpb\wg@tmpd=-\wg@tmpd%3
+ \or% 4
+ \wg@tmpa=-\wg@tmpa\wg@tmpc=-\wg@tmpc%
+ \wg@tmpb=-\wg@tmpb\wg@tmpd=-\wg@tmpd%
+ \fi
+ \hex@bevel@path{chit/bevel shadow}
+ \fi
+% \end{macrocode}
+% \begin{macrocode}
\endscope%
% \end{macrocode}
%