Debian Codegraph @

texmf-dist/tex/latex/tikzlings/tikzlings-wolves.sty

raw
1 % !TeX root = ./examples/wolf.tex
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %%
4 %% This package is part of the TikZlings package
5 %% A package to bring cute little animals and other beings into tikz
6 %% Maintained by samcarter
7 %%
8 %% Project repository and bug tracker:
9 %% https://github.com/samcarter/tikzlings
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{tikzlings-wolves}[2025/12/11 version v2.5 Drawing wolves in TikZ]
16
17 \RequirePackage{tikz}
18 \RequirePackage{tikzlings-addons}
19 \usetikzlibrary{decorations.pathmorphing}
20
21 \newcommand*{\wolf}[1][]{%
22 \begin{scope}%
23 \tikzset{/wolf/.cd,#1}%
24 \wolf@draw%
25 \end{scope}%
26 \thing[#1]%
27 % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 \UseHook{tikzlings/wolf/foreground}
29 \UseHook{tikzlings/tikzling/foreground}
30 \csname wolfhookforeground\endcsname
31 \csname tikzlinghookforeground\endcsname
32 %
33 }
34
35 \newif\ifwolf@threeD
36 \newif\ifwolf@rotatearms
37 \newif\ifwolf@leftstep
38 \newif\ifwolf@rightstep
39 \newif\ifwolf@back
40 \newif\ifwolf@contour
41
42 \NewHook{tikzlings/wolf/background}
43 \NewHook{tikzlings/wolf/belly}
44 \NewHook{tikzlings/wolf/body}
45 \NewHook{tikzlings/wolf/foreground}
46
47 \tikzset{
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %
50 % Pass unknown keys on to tikz
51 %
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 /wolf/.search also={/tikz,/pgf,/thing},
54 /wolf/.cd,
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 %
57 % body
58 %
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 body/.store in = \wolf@body,
61 body = gray!90!white,
62 eyes/.store in = \wolf@eyes,
63 eyes = white,
64 eye/.forward to = /wolf/eyes,
65 pupils/.store in = \wolf@pupils,
66 pupils = black,
67 pupil/.forward to = /wolf/pupils,
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %
70 % options
71 %
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 3D/.code = \wolf@threeDtrue,
74 rotatearms/.code = \wolf@rotatearmstrue
75 \def\wolf@rotatearms{#1},
76 rotate arms/.forward to = /wolf/rotatearms,
77 rotatearms = -50,
78 leftstep/.code = \wolf@leftsteptrue,
79 left step/.forward to = /wolf/leftstep,
80 rightstep/.code = \wolf@rightsteptrue,
81 right step/.forward to = /wolf/rightstep,
82 back/.code = \wolf@backtrue,
83 contour/.code = \wolf@contourtrue
84 \def\wolf@contour{#1},
85 contour/.default = black,
86 outline/.forward to = /wolf/contour,
87 }
88
89 \def\wolf@draw{%
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 %
92 % minimal bounding box size
93 %
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 \path (-0.625,0.1) rectangle (0.905, 2.17);
96 %
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 %
99 % store the current scale factor
100 % from https://github.com/samcarter/tikzlings/issues/3#issuecomment-461373494
101 %
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 \pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
104 \pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))*sqrt(abs((\pgf@xx/1cm)*(\pgf@yy/1cm)-(\pgf@xy/1cm)*(\pgf@yx/1cm)))}%
105 \pgfmathsetmacro{\xscalefactor}{\tmpscaleA}
106 \pgfmathsetmacro{\yscalefactor}{\tmpscaleD}
107 %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 %
110 % switch between 2D, 3D and contours, from
111 % https://chat.stackexchange.com/transcript/message/45991801#45991801
112 %
113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 \ifwolf@threeD
115 \def\wolf@part@draw[##1]{\shade[ball color=##1]}
116 \else% 3D
117 \ifwolf@contour
118 \def\wolf@part@draw[##1]{\draw[##1,\wolf@contour,fill=white,line width=\scalingfactor*0.4pt]}
119 \else% contour
120 \def\wolf@part@draw[##1]{\fill[##1]}
121 \fi% contour
122 \fi% 3D
123 %
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 %
126 % Body parts
127 %
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 %
130 % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 \UseHook{tikzlings/wolf/background}
132 \UseHook{tikzlings/background}
133 \csname wolfhookbackground\endcsname
134 \csname tikzlinghookbackground\endcsname
135 %
136 % Feet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 \ifwolf@leftstep
138 \wolf@part@draw[\wolf@body!65!white] (-0.255,0.25) ellipse[x radius=0.23, y radius=0.09];
139 \else% step
140 \wolf@part@draw[\wolf@body!65!white] (-0.255,0.2) ellipse[x radius=0.23, y radius=0.09];
141 \fi% step
142 %
143 \ifwolf@rightstep
144 \wolf@part@draw[\wolf@body!65!white] (0.255,0.25) ellipse[x radius=0.23, y radius=0.09];
145 \else% step
146 \wolf@part@draw[\wolf@body!65!white] (0.255,0.2) ellipse[x radius=0.23, y radius=0.09];
147 \fi% step
148 %
149 % Ears %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 \wolf@part@draw[\wolf@body] (0.22, 2.0392) .. controls (0.22, 2.1584) and (0.49460, 2.255) .. (0.49460, 2.255) .. controls (0.49460, 2.255) and (0.5300, 1.86) .. (0.3721, 1.86) .. controls (0.2891, 1.86) and (0.22, 1.9201) .. (0.22, 2.0392) -- cycle;
151 \wolf@part@draw[\wolf@body!55!white] (0.22, 2.0392) .. controls (0.26, 2.1584) and (0.47, 2.22) .. (0.47, 2.20) .. controls (0.47, 2.2) and (0.49, 1.9) .. (0.3721, 1.9) .. controls (0.2891, 1.88) and (0.22, 1.88) .. (0.22, 2.0392) -- cycle;
152 \wolf@part@draw[\wolf@body] (-0.22, 2.0392) .. controls (-0.22, 2.1584) and (-0.49460, 2.255) .. (-0.49460, 2.255) .. controls (-0.49460, 2.255) and (-0.5300, 1.86) .. (-0.3721, 1.86) .. controls (-0.2891, 1.86) and (-0.22, 1.9201) .. (-0.22, 2.0392) -- cycle;
153 \wolf@part@draw[\wolf@body!55!white] (-0.22, 2.0392) .. controls (-0.26, 2.1584) and (-0.47, 2.22) .. (-0.47, 2.20) .. controls (-0.47, 2.2) and (-0.49, 1.9) .. (-0.3721, 1.9) .. controls (-0.2891, 1.88) and (-0.22, 1.88) .. (-0.22, 2.0392) -- cycle;
154 %
155 % Tail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 \unless\ifwolf@back
157 \wolf@part@draw[\wolf@body!50!darkgray] (1.0893, 1.5779) .. controls (0.3433, 1.6612) and (0.4863, 0.6062) .. (-0.0243, 0.348) .. controls (1.0671, 0.068) and (0.8133, 1.1808) .. (1.0893, 1.5779) -- cycle;
158 \fi%back
159 %
160 % Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 \wolf@part@draw[\wolf@body!80!white,rotate around={-\wolf@rotatearms:(-0.36,1.3)}] (-0.8,1.3) ellipse[x radius=0.42, y radius=0.13];
162 \wolf@part@draw[\wolf@body!80!white,rotate around={\wolf@rotatearms:(0.36,1.3)}] (0.8,1.3) ellipse[x radius=0.42, y radius=0.13];
163 %
164 % Body %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 \wolf@part@draw[\wolf@body] (0.595, 0.92) .. controls (0.595, 0.26) and (0.355, 0.18) .. (0, 0.18) .. controls (-0.355, 0.18) and (-0.595, 0.26) .. (-0.595, 0.92) .. controls (-0.605, 1.58) and (-0.335, 2.11) .. (0, 2.11) .. controls (0.335, 2.11) and (0.605, 1.58) .. (0.595, 0.92) -- cycle;
166 %
167 % Tail in Back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 \ifwolf@back
169 \wolf@part@draw[\wolf@body!50!darkgray] (1.0893, 1.5779) .. controls (0.3433, 1.6612) and (0.4863, 0.6062) .. (-0.0243, 0.348) .. controls (1.0671, 0.068) and (0.8133, 1.1808) .. (1.0893, 1.5779) -- cycle;
170 \fi%back
171 %
172 % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 \UseHook{tikzlings/wolf/belly}
174 \UseHook{tikzlings/belly}
175 \csname wolfhookbelly\endcsname
176 \csname tikzlinghookbelly\endcsname
177 %
178 % Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 \ifwolf@back
180 \wolf@part@draw[\wolf@body!70!white!95!brown] (0.5, 1.8) .. controls (0.5, 1.58) and (0.2, 1.35) .. (0, 1.35) .. controls (-0.2, 1.35) and (-0.5, 1.58) .. (-0.5, 1.8) .. controls (-0.34, 2.3) and (0.34, 2.3) .. (0.5, 1.8) -- cycle;
181 \else% back
182 \wolf@part@draw[\wolf@body!70!white!95!brown] (0.5, 1.8) .. controls (0.5, 1.58) and (0.2, 1.25) .. (0, 1.16) .. controls (-0.2, 1.25) and (-0.5, 1.58) .. (-0.5, 1.8) .. controls (-0.34, 2.3) and (0.34, 2.3) .. (0.5, 1.8) -- cycle;
183 \fi% back
184 %
185 % Cheeks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 \unless\ifwolf@back
187 \wolf@part@draw[\wolf@body!40!white!80!brown] (-0.4935, 1.7443) .. controls (-0.4935, 1.7443) and (-0.1917, 1.7798) .. (-0.1371, 1.7333) .. controls (-0.07, 1.2) and (-0.07, 1.2) .. (-0.07, 1.2) .. controls (-0.259, 1.3169) and (-0.46, 1.5665) .. (-0.4935, 1.7443) -- cycle
188 (0.4935, 1.7443) .. controls (0.4935, 1.7443) and (0.1917, 1.7798) .. (0.1371, 1.7333) .. controls (0.07, 1.2) and (0.07, 1.2) .. (0.07, 1.2) .. controls (0.259, 1.3169) and (0.46, 1.5665) .. (0.4935, 1.7443) -- cycle;
189 \fi% back
190 %
191 % Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 \unless\ifwolf@back
193 \wolf@part@draw[\wolf@eyes] (-0.1514, 1.6791) .. controls (-0.1514, 1.6791) and (-0.1951, 1.6471) .. (-0.2341, 1.6584) .. controls (-0.2731, 1.6697) and (-0.2927, 1.72) .. (-0.2927, 1.72) .. controls (-0.2927, 1.72) and (-0.2492, 1.7521) .. (-0.2102, 1.7408) .. controls (-0.1712, 1.7295) and (-0.1514, 1.6791) .. (-0.1514, 1.6791) -- cycle;
194 \wolf@part@draw[\wolf@eyes] (0.1514, 1.6791) .. controls (0.1514, 1.6791) and (0.1951, 1.6471) .. (0.2341, 1.6584) .. controls (0.2731, 1.6697) and (0.2927, 1.72) .. (0.2927, 1.72) .. controls (0.2927, 1.72) and (0.2492, 1.7521) .. (0.2102, 1.7408) .. controls (0.1712, 1.7295) and (0.1514, 1.6791) .. (0.1514, 1.6791) -- cycle;
195 \fi% back
196 %
197 % pupil %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 \unless\ifwolf@back
199 \wolf@part@draw[\wolf@pupils] (0.22, 1.695) circle[radius=0.025];
200 \wolf@part@draw[\wolf@pupils] (-0.22, 1.695) circle[radius=0.025];
201 \fi% back
202 %
203 % Hair and Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 \ifwolf@back
205 % Hair from Back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 \wolf@part@draw[\wolf@body!50!darkgray,decorate,decoration={zigzag,amplitude=\scalingfactor*0.3pt,segment length=\scalingfactor*2.5pt}] (-0.1,1.92) -- (-0.275,2.1) -- (-0.1,2.2) -- (0.1,2.2) -- (0.275,2.1) -- (0.1,1.92) -- cycle;
207 \else% back
208 % Hair from Front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 \wolf@part@draw[\wolf@body!50!darkgray,decorate,decoration={zigzag,amplitude=\scalingfactor*0.3pt,segment length=\scalingfactor*2.5pt}] (0,1.6) -- (-0.1,1.92) -- (-0.275,2.1) -- (-0.1,2.2) -- (0.1,2.2) -- (0.275,2.1) -- (0.1,1.92) -- cycle;
210 % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 \wolf@part@draw[\wolf@body!50!black] (0, 1.24) ellipse[x radius=0.07,y radius=0.05];
212 %
213 \fi% back
214 %
215 % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 \UseHook{tikzlings/wolf/body}
217 \UseHook{tikzlings/body}
218 \csname wolfhookbody\endcsname
219 \csname tikzlinghookbody\endcsname
220 %
221 }
222
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 %%
225 %% Documentation
226 %%
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 %\clearpage
229 %\section[Wolf]{Westy, the wolf}
230 %
231 %\emph{The wolf was kindly contributed by @cfroccajr. It is named ``Westy'' for the Western CT State University, whose new mascot is a wolf.}
232 %
233 %\subsection{Package name}
234 %
235 %\begin{tcolorbox}[title={Package usage}]
236 %\begin{samcode}
237 %\usepackage{tikzlings-wolves}
238 %\end{samcode}
239 %\end{tcolorbox}
240 %
241 %\subsection{Basic Usage}
242 %
243 %\begin{tcblisting}{title={Basic wolf}}
244 %\wolf
245 %\end{tcblisting}
246 %
247 %\subsection{Options}
248 %
249 %The basic wolf can be modified by changing its colour:
250 %\begin{tcblisting}{title={Body colour}}
251 %\wolf[body=blue]
252 %\end{tcblisting}
253 %
254 %In addition to the colour of the body, the colour of the eyes can be adjusted:
255 %\begin{tcblisting}{title={Eye colour}}
256 %\wolf[eyes=red]
257 %\end{tcblisting}
258 %\begin{tcblisting}{title={Pupil Colour}}
259 %\wolf[pupils=red]
260 %\end{tcblisting}
261 %
262 %The rotation angle of its arms can be adjusted:
263 %\begin{tcblisting}{title={Rotating the arms}}
264 %\wolf[rotatearms=40]
265 %\end{tcblisting}
266 %
267 %And the wolf can lift its legs:
268 %\begin{tcblisting}{title={Walking}}
269 %\wolf[leftstep]
270 %\wolf[rightstep,xshift=2cm]
271 %\end{tcblisting}
272 %
273 %To view the wolf from behind:
274 %\begin{tcblisting}{title={Back view}}
275 %\wolf[back]
276 %\end{tcblisting}
277 %
278 %The key \saminline|3D| will make the wolf 3-dimensional:
279 %\begin{tcblisting}{title={3D view}}
280 %\wolf[3D]
281 %\end{tcblisting}
282 %
283 %And finally the \saminline|contour| key will only draw the outlines:
284 %\begin{tcblisting}{title={Contours}}
285 %\wolf[contour=black]
286 %\end{tcblisting}