%% %% This is file `tikzlibrarywargame.util.code.tex', %% generated with the docstrip utility. %% %% The original source files were: %% %% util/core.dtx (with options: `utils') %% %% Copyright (C) 2019 Christian Holm. %% %% This file is NOT the source for wargame, because almost all comments %% have been stripped from it. It is NOT the preferred form of universal %% for making modifications to it. %% %% Therefore you can NOT redistribute and/or modify THIS file. You can %% however redistribute the complete source (wargame.dtx and wargame.ins) %% and/or modify it under the terms of the GNU General Public License as %% published by the Free Software Foundation; either version 2, or (at %% your option) any later version. %% %% The wargame package is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %% General Public License for more details. %% %% You should have received a copy of the GNU General Public %% License along with this package; if not, write to the %% Free Software Foundation, Inc., %% 675 Mass Ave, Cambridge, %% MA 02139, USA. %% %% See the file wargame.dtx for further comments and documentation. %% \newcount\wargamedbglvl\wargamedbglvl=0 \def\wg@dbg#1#2{% \ifnum#1>\wargamedbglvl\relax\else\message{^^J#2}\fi} \long\def\wg@addto@macro#1#2{% \begingroup \toks@\expandafter\expandafter\expandafter{\expandafter#1#2}% \xdef#1{\the\toks@}% \endgroup} \def\wg@sub@nchor#1#2{% \wg@dbg{3}{^^JGet `#2' in `#1'}% \@ifundefined{pgf@sh@ns@#1}{% \pgf@x=0cm\pgf@y=0cm}{% \pgf@process{% \csname pgf@sh@ma@#1\endcsname% MW \csname pgf@sh@np@#1\endcsname% \pgf@sh@reanchor{\csname pgf@sh@ns@#1\endcsname}{#2}}}% \wg@dbg{10}{-> \the\pgf@x,\the\pgf@y}% } \newdimen\wg@tmpa \newdimen\wg@tmpb \newdimen\wg@tmpc \newdimen\wg@tmpd \def\settosave#1{ \pgfsyssoftpath@setcurrentpath{#1}} \def\wg@pic{% \@ifnextchar[{\wg@@pic}{\wg@@pic[]}%] } \def\wg@@pic[#1]#2\@endwg@pic{% \wg@dbg{2}{Options: `#1', picture: `#2'}% \wg@@@pic{#1}{#2}% } \def\wg@@@pic#1#2#3#4#5{% \ifx|#2|\wg@dbg{3}{No picture given}% \else% \wg@dbg{3}{^^JWG Pic: ^^J User options: #1 ^^J Picture: #2 ^^J Prefix: #3 ^^J Coordinates: #4 ^^J Fixed options: #5}% % \wg@dbg{2}{\string\pic[#5,#1] at (#4) {#3#2}}% \pic[#5,#1] at (#4) {#3#2};% \ifwg@s@ve% \pgf@relevantforpicturesizetrue% \begin{getbbl}% \pic[draw=none,fill=none,transform shape] at (#4) {#3#2};% \end{getbbl}% \wg@dbg{5}{Clipping to local bounding box}% \clip (L.south west) rectangle (L.north east);% \pgf@relevantforpicturesizefalse \global\wg@s@vefalse% \fi \fi% \wg@dbg{3}{End of WG Pic} } \def\wg@pic@all#1#2#3#4{% \wg@dbg{2}{WG picture loop ^^J List: \meaning#1 ^^J Prefix: `#2' ^^J Position: `#3' ^^J Styles: `#4'} \foreach \p in #1{% \wg@dbg{2}{WG picture element: \meaning\p}% \expandafter\wg@pic\p\@endwg@pic {#2}{#3}{#4}% }% } \def\wg@node{% \@ifnextchar[{\wg@@node}{\wg@@node[]}%] } \def\wg@@node[#1]#2\@endwg@node{% \wg@dbg{2}{Options: `#1', body: `#2'}% \wg@@@node{#1}{#2}% } \def\wg@@@node#1#2#3#4#5{% \ifx|#2|\wg@dbg{3}{No body given}% \else% \wg@dbg{3}{^^JWG Pic: ^^J User options: #1 ^^J Body: #2 ^^J Prefix: #3 ^^J Coordinates: #4 ^^J Fixed options: #5}% % \wg@dbg{2}{\string\pic[#5,#1] at (#4) {#3#2}}% \node[#5,#1] at (#4) {#3#2};% \fi% \wg@dbg{3}{End of WG Node} } \def\wg@node@all#1#2#3#4{% \wg@dbg{2}{WG picture loop ^^J List: \meaning#1 ^^J Prefix: `#2' ^^J Position: `#3' ^^J Styles: `#4'} \foreach \p in #1{% \wg@dbg{2}{WG picture element: \meaning\p}% \expandafter\wg@node\p\@endwg@node {#2}{#3}{#4}% }% } \newdimen\wg@bb@minx \newdimen\wg@bb@miny \newdimen\wg@bb@maxx \newdimen\wg@bb@maxy \newif\ifwg@notrelevantforpathsize\wg@notrelevantforpathsizefalse \def\wg@resetbb{% \global\wg@bb@minx=16000pt\relax% \global\wg@bb@miny=16000pt\relax% \global\wg@bb@maxx=-16000pt\relax% \global\wg@bb@maxy=-16000pt\relax% } \let\old@pgf@protocolsize\pgf@protocolsizes \def\wg@protocolsizes#1#2{% \old@pgf@protocolsize{#1}{#2} \ifwg@notrelevantforpathsize\else% \ifdim#1<\wg@bb@minx\global\wg@bb@minx#1\fi% \ifdim#1>\wg@bb@maxx\global\wg@bb@maxx#1\fi% \ifdim#2<\wg@bb@miny\global\wg@bb@miny#2\fi% \ifdim#2>\wg@bb@maxy\global\wg@bb@maxy#2\fi% \fi } \newenvironment{getbbl}{% \wg@resetbb% \wg@notrelevantforpathsizefalse% \global\let\pgf@protocolsizes\wg@protocolsizes}{% \gdef\pgf@sh@ns@L{rectangle} \gdef\pgf@sh@np@L{% \def\southwest{\pgfqpoint{\the\wg@bb@minx}{\the\wg@bb@miny}}% \def\northeast{\pgfqpoint{\the\wg@bb@maxx}{\the\wg@bb@maxy}}% } \gdef\pgf@sh@nt@L{{1}{0}{0}{1}{0pt}{0pt}} \gdef\pgf@sh@pi@L{\pgfpictureid} \global\let\pgf@protocolsizes\old@pgf@protocolsize } \newenvironment{getbb}{% \wg@resetbb% \wg@notrelevantforpathsizefalse% \global\let\pgf@protocolsizes\wg@protocolsizes}{% \gdef\pgf@sh@ns@M{rectangle} \gdef\pgf@sh@np@M{% \def\southwest{\pgfqpoint{\the\wg@bb@minx}{\the\wg@bb@miny}}% \def\northeast{\pgfqpoint{\the\wg@bb@maxx}{\the\wg@bb@maxy}}% } \gdef\pgf@sh@nt@M{{1}{0}{0}{1}{0pt}{0pt}} % \pgfgettransform\pgf@temp% % \xdef\pgf@sh@nt@M{\pgf@temp} % \pgfgettransformentries{\wg@tmp@a}{\wg@tmp@b}{\wg@tmp@c}{\wg@tmp@d}{\pgf@temp}{\pgf@temp} % \message{^^JTransform of M: \meaning\pgf@temp} % \xdef\pgf@sh@nt@M{{\wg@tmp@a}{\wg@tmp@b}{\wg@tmp@c}{\wg@tmp@d}{0pt}{0pt}}% % \message{^^JTransform of M: \meaning\pgf@sh@nt@M} \gdef\pgf@sh@pi@M{\pgfpictureid} \global\let\pgf@protocolsizes\old@pgf@protocolsize } \tikzstyle{reverseclip}=[insert path={(current bounding box.north east) -- (current bounding box.south east) -- (current bounding box.south west) -- (current bounding box.north west) -- (current bounding box.north east)}] \tikzset{ clip even odd rule/.code={\pgfseteorule}, % Credit to Andrew Stacey } \tikzset{ invclip/.style={ clip,insert path= [clip even odd rule]{ [reset cm](-\maxdimen,-\maxdimen)rectangle(\maxdimen,\maxdimen) } }, } \newif\ifwg@s@ve\wg@s@vefalse \tikzset{ save clip/.is choice, save clip/true/.code={\global\wg@s@vetrue}, save clip/false/.code={\global\wg@s@vefalse}, save clip/.default={true}, save clip/.initial={false}, } \tikzset{ scale line widths/.style={% /utils/exec=\def\tikz@semiaddlinewidth##1{% \pgfgettransformentries{% \wg@jaca}{% \wg@jacb}{% \wg@jacc}{% \wg@jacd}{% \wg@tmp}{% \wg@tmp}% \pgfmathsetmacro{\wg@jac}{sqrt(abs(\wg@jaca*\wg@jacd-\wg@jacb*\wg@jacc))}% \wg@dbg{4}{Scaling line width ##1 by \wg@jac} \pgfmathsetmacro{\wg@lw}{\wg@jac*##1}% \wg@dbg{4}{Scaled ##1 -> \wg@lw} \tikz@addoption{\pgfsetlinewidth{\wg@lw pt}}% \wg@dbg{4}{Added scaled option \wg@lw} \pgfmathsetlength\pgflinewidth{\wg@lw pt} \wg@dbg{4}{Did set line width \wg@lw pt} }}, relative line width/.style={% /utils/exec=\def\tikz@semiaddlinewidth##1{% \wg@dbg{4}{Relative line width #1 times ##1}% \pgfmathsetmacro{\wg@lv}{#1*##1}% \tikz@addoption{\pgfsetlinewidth{\wg@lw pt}}% \pgfmathsetlength\pgflinewidth{\wg@lw pt}}} } \tikzset{ sub pic actions/.code={% \tikz@picmode% \edef\opts{% \iftikz@mode@draw draw,\else draw=none,\fi \iftikz@mode@fill fill\else fill=none\fi} \wg@dbg{5}{^^JSub Mode: \meaning\tikz@picmode \meaning\opts} \pgfset{/tikz/.cd} \pgfkeysalsofrom{\opts} }} \tikzset{ wg/debug show/.code={% \extractcolorspec{pgfstrokecolor}{\wg@tmp@fg} \def\wg@tmp@bg{none} \@ifundefinedcolor{pgffillcolor}{}{ \extractcolorspec{pgffillcolor}{\wg@tmp@bg}} \begingroup \tikz@mode \wargamedbglvl=#1 \wg@dbg{3}{Drawing with w/stroke `\wg@tmp@fg' (\tikz@strokecolor,\iftikz@mode@draw\else not\space\fi drawing) and fill `\wg@tmp@bg' (\tikz@fillcolor,\iftikz@mode@fill\else not\space\fi filling)} \endgroup } } \def\wg@r@ndom@id{% \def\wg@uuid{} \foreach \i in {1,...,8}{% \pgfmathparse{Hex(random(0,15))} \xdef\wg@uuid{\wg@uuid\pgfmathresult}}} %% Local Variables: %% mode: LaTeX %% End: %% %% End of file `tikzlibrarywargame.util.code.tex'.