% \iffalse % -------------------------------------------------------------------- %<*hex> % \fi % \begin{TikzKey}{hex/terrain/speckle} % The style for speckled hexes. The pattern is circles of varying % opacity to overlay on a fill colour, so as to create variations in % how the terrain comes out. % % \begin{macrocode} \tikzset{ hex/terrain/speckle/.style={% }% } % \end{macrocode} % \end{TikzKey} % % \begin{TikzKey}{hex/terrain/fields} % Now for the actual pattern. % % \begin{center} % \includegraphics{wargame.fields} % \end{center} % % \begin{macrocode} \ifhex@terrain@pic \pgfmathdeclarerandomlist{black white speckles}{{black}{white}} \pgfmathdeclarerandomlist{gray white speckles}{{gray}{white}} \tikzset{ hex/terrain/speckle/minimum radius/.initial=3, hex/terrain/speckle/maximum radius/.initial=10, hex/terrain/speckle/minimum opacity/.initial=3, hex/terrain/speckle/maximum opacity/.initial=7, %% pics/hex/terrain/speckle/.style args={#1,#2}{ code={ \tikzset{ hex/terrain/speckle/minimum radius/.get=\minR, hex/terrain/speckle/maximum radius/.get=\maxR, hex/terrain/speckle/minimum opacity/.get=\minO, hex/terrain/speckle/maximum opacity/.get=\maxO, } \foreach \i in {1,...,#1}{ \pgfmathrandominteger{\R}{\minR}{\maxR} \pgfmathrandominteger{\n}{1}{3}% Sub trapezoid \pgfmathrandominteger{\x}{0}{100}% X coordinate \pgfmathrandominteger{\y}{0}{100}% Y coordinate \pgfmathrandominteger{\o}{\minO}{\maxO}% Opacity \pgfmathrandomitem{\c}{#2} \pgfmathparse{\x/100}\edef\x{\pgfmathresult} \pgfmathparse{\y/100}\edef\y{\pgfmathresult} \pgfmathparse{\R/100}\edef\R{\pgfmathresult} \pgfmathparse{\o/100}\edef\o{\pgfmathresult} \pgfmathparse{1-\R}\edef\O{\pgfmathresult} \ifnum\n=1 \fill[\c,opacity=\o]($\y*(120:\O)+(\x-\R,0)$) circle(\R); \else \ifnum\n=2 \fill[\c,opacity=\o]($\y*(240:\O)+(\x-\R,0)$) circle(\R); \else \fill[\c,opacity=\o]($\x*(120:\O)+\y*(240:\O)$) circle(\R); \fi \fi } } }, pics/hex/terrain/speckle/.default={200,gray white speckles} } \fi % \end{macrocode} % \end{TikzKey} % \iffalse % % -------------------------------------------------------------------- % \fi