| 1 |
% \iffalse |
| 2 |
% -------------------------------------------------------------------- |
| 3 |
%<*hex> |
| 4 |
% \fi |
| 5 |
% \begin{TikzKey}{hex/terrain/speckle} |
| 6 |
% The style for speckled hexes. The pattern is circles of varying |
| 7 |
% opacity to overlay on a fill colour, so as to create variations in |
| 8 |
% how the terrain comes out. |
| 9 |
% |
| 10 |
% \begin{macrocode} |
| 11 |
\tikzset{ |
| 12 |
hex/terrain/speckle/.style={% |
| 13 |
}% |
| 14 |
} |
| 15 |
% \end{macrocode} |
| 16 |
% \end{TikzKey} |
| 17 |
% |
| 18 |
% \begin{TikzKey}{hex/terrain/fields} |
| 19 |
% Now for the actual pattern. |
| 20 |
% |
| 21 |
% \begin{center} |
| 22 |
% \includegraphics{wargame.fields} |
| 23 |
% \end{center} |
| 24 |
% |
| 25 |
% \begin{macrocode} |
| 26 |
\ifhex@terrain@pic |
| 27 |
\pgfmathdeclarerandomlist{black white speckles}{{black}{white}} |
| 28 |
\pgfmathdeclarerandomlist{gray white speckles}{{gray}{white}} |
| 29 |
\tikzset{ |
| 30 |
hex/terrain/speckle/minimum radius/.initial=3, |
| 31 |
hex/terrain/speckle/maximum radius/.initial=10, |
| 32 |
hex/terrain/speckle/minimum opacity/.initial=3, |
| 33 |
hex/terrain/speckle/maximum opacity/.initial=7, |
| 34 |
%% |
| 35 |
pics/hex/terrain/speckle/.style args={#1,#2}{ |
| 36 |
code={ |
| 37 |
\tikzset{ |
| 38 |
hex/terrain/speckle/minimum radius/.get=\minR, |
| 39 |
hex/terrain/speckle/maximum radius/.get=\maxR, |
| 40 |
hex/terrain/speckle/minimum opacity/.get=\minO, |
| 41 |
hex/terrain/speckle/maximum opacity/.get=\maxO, |
| 42 |
} |
| 43 |
\foreach \i in {1,...,#1}{ |
| 44 |
|
| 45 |
\pgfmathrandominteger{\R}{\minR}{\maxR} |
| 46 |
\pgfmathrandominteger{\n}{1}{3}% Sub trapezoid |
| 47 |
\pgfmathrandominteger{\x}{0}{100}% X coordinate |
| 48 |
\pgfmathrandominteger{\y}{0}{100}% Y coordinate |
| 49 |
\pgfmathrandominteger{\o}{\minO}{\maxO}% Opacity |
| 50 |
\pgfmathrandomitem{\c}{#2} |
| 51 |
\pgfmathparse{\x/100}\edef\x{\pgfmathresult} |
| 52 |
\pgfmathparse{\y/100}\edef\y{\pgfmathresult} |
| 53 |
\pgfmathparse{\R/100}\edef\R{\pgfmathresult} |
| 54 |
\pgfmathparse{\o/100}\edef\o{\pgfmathresult} |
| 55 |
\pgfmathparse{1-\R}\edef\O{\pgfmathresult} |
| 56 |
\ifnum\n=1 |
| 57 |
\fill[\c,opacity=\o]($\y*(120:\O)+(\x-\R,0)$) circle(\R); |
| 58 |
\else |
| 59 |
\ifnum\n=2 |
| 60 |
\fill[\c,opacity=\o]($\y*(240:\O)+(\x-\R,0)$) circle(\R); |
| 61 |
\else |
| 62 |
\fill[\c,opacity=\o]($\x*(120:\O)+\y*(240:\O)$) circle(\R); |
| 63 |
\fi |
| 64 |
\fi |
| 65 |
} |
| 66 |
} |
| 67 |
}, |
| 68 |
pics/hex/terrain/speckle/.default={200,gray white speckles} |
| 69 |
} |
| 70 |
\fi |
| 71 |
% \end{macrocode} |
| 72 |
% \end{TikzKey} |
| 73 |
% \iffalse |
| 74 |
%</hex> |
| 75 |
% -------------------------------------------------------------------- |
| 76 |
% \fi |