| 1 |
% !TeX root = ./testing/test.tex |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% |
| 4 |
% The tikzmarmots package |
| 5 |
% A package to bring little marmots into tikz |
| 6 |
% Maintained by samcarter |
| 7 |
% |
| 8 |
% Project repository and bug tracker: |
| 9 |
% https://github.com/samcarter/tikzmarmots |
| 10 |
% |
| 11 |
% Released under the LaTeX Project Public License v1.3c or later |
| 12 |
% See https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 15 |
\ProvidesPackage{tikzmarmots} |
| 16 |
[2018/11/09 v1.0 Drawing marmots in TikZ] |
| 17 |
|
| 18 |
\PackageWarning{tikzmarmots}{The TikZmarmots package was merged into the TikZlings package, please load the package `tikzlings-marmots` or the more general `tikzlings` package instead} |
| 19 |
|
| 20 |
\RequirePackage{tikz} |
| 21 |
\usetikzlibrary{shadows.blur} |
| 22 |
\usetikzlibrary{fadings} |
| 23 |
|
| 24 |
\tikzfading[name=marmot@blush, |
| 25 |
inner color=transparent!50, |
| 26 |
outer color=transparent!100] |
| 27 |
|
| 28 |
\RequirePackage{ifluatex} |
| 29 |
\RequirePackage{ifxetex} |
| 30 |
|
| 31 |
\ifluatex |
| 32 |
\let\pdfrandomseed\randomseed |
| 33 |
\fi |
| 34 |
|
| 35 |
\ifxetex |
| 36 |
\pgfmathsetseed{\time} |
| 37 |
\else |
| 38 |
\pgfmathsetseed{\number\pdfrandomseed} |
| 39 |
\fi |
| 40 |
|
| 41 |
\newcommand*{\marmot}[1][]{% |
| 42 |
\begin{scope}% |
| 43 |
\tikzset{/marmot/.cd,#1}% |
| 44 |
\marmot@draw% |
| 45 |
\end{scope}% |
| 46 |
} |
| 47 |
|
| 48 |
\newif\ifmarmot@blush |
| 49 |
\newif\ifmarmot@whiskers |
| 50 |
\newif\ifmarmot@teeth |
| 51 |
\newif\ifmarmot@threeD |
| 52 |
\newif\ifmarmot@shadow |
| 53 |
\newif\ifmarmot@askphil |
| 54 |
|
| 55 |
\tikzset{ |
| 56 |
% |
| 57 |
% Pass unknown keys on to tikz |
| 58 |
% |
| 59 |
/marmot/.search also={/tikz,/pgf}, |
| 60 |
/marmot/.cd, |
| 61 |
% |
| 62 |
% body |
| 63 |
% |
| 64 |
body/.code = \def\marmot@body{#1}, |
| 65 |
body = brown, |
| 66 |
% |
| 67 |
% options |
| 68 |
% |
| 69 |
blush/.code = \marmot@blushtrue, |
| 70 |
whiskers/.code = \marmot@whiskerstrue \def\marmot@whiskers{#1}, |
| 71 |
whiskers/.default = gray, |
| 72 |
teeth/.code = \marmot@teethtrue, |
| 73 |
3D/.code = \marmot@threeDtrue, |
| 74 |
shadow/.code = \marmot@shadowtrue, |
| 75 |
askphil/.code = \marmot@askphiltrue, |
| 76 |
ask phil/.forward to=/marmot/askphil, |
| 77 |
} |
| 78 |
|
| 79 |
\def\marmot@draw{% |
| 80 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 |
% |
| 82 |
% minimal bounding box size |
| 83 |
% |
| 84 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 85 |
\path (0.3,0.1) rectangle (1.83,2.17); |
| 86 |
% |
| 87 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 88 |
% |
| 89 |
% switch between 2D and 3D, from |
| 90 |
% https://chat.stackexchange.com/transcript/message/45991801#45991801 |
| 91 |
% |
| 92 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 93 |
\ifmarmot@threeD |
| 94 |
\def\marmot@part@draw##1{\shade[ball color=##1]} |
| 95 |
\else |
| 96 |
\def\marmot@part@draw##1{\fill[##1]} |
| 97 |
\fi |
| 98 |
% |
| 99 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 100 |
% |
| 101 |
% shadow |
| 102 |
% |
| 103 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 104 |
% |
| 105 |
\ifmarmot@askphil |
| 106 |
\pgfmathparse{int(random(1,120))} |
| 107 |
\let\marmot@random=\pgfmathresult |
| 108 |
\ifnum\marmot@random>17 |
| 109 |
\marmot@shadowtrue |
| 110 |
\fi |
| 111 |
\fi |
| 112 |
% |
| 113 |
\ifmarmot@shadow |
| 114 |
\fill[opacity=0,blur shadow,rotate=-80] (-0.25,1.3) ellipse (0.28 and 0.8); |
| 115 |
\fi |
| 116 |
% |
| 117 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 118 |
% |
| 119 |
% Body parts (center: x=0.925) |
| 120 |
% |
| 121 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 122 |
% |
| 123 |
% Feet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 124 |
\marmot@part@draw{\marmot@body!50!black} (1.18,0.2) ellipse (0.23 and 0.09); |
| 125 |
\marmot@part@draw{\marmot@body!50!black} (0.67,0.2) ellipse (0.23 and 0.09); |
| 126 |
% |
| 127 |
% Ears %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 128 |
\marmot@part@draw{\marmot@body!50!black} (1.18,2.03) ellipse (0.09 and 0.13); |
| 129 |
\marmot@part@draw{\marmot@body!50!black} (0.67,2.03) ellipse (0.09 and 0.13); |
| 130 |
% |
| 131 |
% Tail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 132 |
\marmot@part@draw{\marmot@body!50!black} (1.81,0.67) .. controls (1.79,0.40) and (1.27,0.24) .. (1.26,0.44) .. controls (1.24,0.56) and (1.37,0.51) .. (1.50,0.53) .. controls (1.62,0.54) and (1.81,0.72) .. (1.81,0.67) -- cycle; |
| 133 |
% |
| 134 |
% Body %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 135 |
\marmot@part@draw{\marmot@body} (1.52,0.92) .. controls (1.52,0.26) and (1.28,0.18) .. (0.925,0.18) .. controls (0.57,0.18) and (0.33,0.26) .. (0.33,0.92) .. controls (0.32,1.58) and (0.59,2.11) .. (0.925,2.11) .. controls (1.26,2.11) and (1.53,1.58) .. (1.52,0.92) -- cycle; |
| 136 |
% |
| 137 |
% Belly %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 138 |
\marmot@part@draw{\marmot@body!50!white} (1.35,0.71) .. controls (1.35,0.41) and (1.17,0.37) .. (0.925,0.37) .. controls (0.68,0.37) and (0.5,0.41) .. (0.5,0.71) .. controls (0.5,1.01) and (0.7,1.26) .. (0.925,1.26) .. controls (1.15,1.26) and (1.35,1.01) .. (1.35,0.71) -- cycle; |
| 139 |
% |
| 140 |
% Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 141 |
\marmot@part@draw{\marmot@body!50!black,rotate around={70:(1.31,0.93)}} (1.31,0.93) ellipse (0.24 and 0.13); |
| 142 |
\marmot@part@draw{\marmot@body!50!black,rotate around={-70:(0.54,0.93)}} (0.54,0.93) ellipse (0.24 and 0.13); |
| 143 |
% |
| 144 |
% Muzzle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 145 |
\marmot@part@draw{\marmot@body!50!white} (0.925,1.47) ellipse (0.23 and 0.13); |
| 146 |
% |
| 147 |
% Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 148 |
\marmot@part@draw{\marmot@body!50!black} (0.925,1.6) circle (0.08); |
| 149 |
% |
| 150 |
% Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 151 |
\marmot@part@draw{\marmot@body!50!black} (0.77,1.77) circle (0.05); |
| 152 |
\marmot@part@draw{\marmot@body!50!black} (1.08,1.77) circle (0.05); |
| 153 |
% |
| 154 |
% Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 155 |
\draw[\marmot@body!50!black] (1.07,1.51) arc [start angle=-20, end angle=-160, radius=0.16]; |
| 156 |
% |
| 157 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 158 |
% |
| 159 |
% optional |
| 160 |
% |
| 161 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 162 |
% |
| 163 |
% Blushed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 164 |
\ifmarmot@blush |
| 165 |
\fill[red,path fading=marmot@blush] (0.63,1.6) circle (0.1); |
| 166 |
\fill[red,path fading=marmot@blush] (1.22,1.6) circle (0.1); |
| 167 |
\fi |
| 168 |
% |
| 169 |
% Wiskers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 170 |
\ifmarmot@whiskers |
| 171 |
\foreach \X in {10,20,33}{% |
| 172 |
\filldraw[line width=0pt,\marmot@whiskers] (0.925,1.6) + (\X:0.08) to[out=\X,in={180-\X}] ++({\X-20}:0.3) --++(0,0.005) to[out={180-\X},in=\X] cycle (0.925,1.6) + ({180-\X}:0.08) to[out={180-\X},in=\X] ++({200-\X}:0.3) --++(0,0.005) to[out=\X,in={180-\X}] cycle; |
| 173 |
} |
| 174 |
\fi |
| 175 |
% |
| 176 |
% Teeth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 177 |
\ifmarmot@teeth |
| 178 |
\draw[very thin,fill=white] (0.88,1.41) -- (0.88,1.38) to[out=-5,in=-175] (0.97,1.38) -- (0.97,1.41) to[out=-170,in=-10] cycle; |
| 179 |
\draw[very thin] (0.925,1.405) -- (0.925,1.38); |
| 180 |
\fi |
| 181 |
% |
| 182 |
} |
| 183 |
|