summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty')
-rw-r--r--graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty318
1 files changed, 193 insertions, 125 deletions
diff --git a/graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty b/graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty
index a7b194cf27..5b5f851352 100644
--- a/graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty
+++ b/graphics/pgf/contrib/tikzlings/tikzlings-snowmen.sty
@@ -1,18 +1,18 @@
-% !TeX root = ./examples/snowman.tex
+ % !TeX root = ./examples/snowman.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% This package is part of the TikZlings package
-% A package to bring cute little animals and other beings into tikz
-% Maintained by samcarter
-%
-% Project repository and bug tracker:
-% https://github.com/samcarter/tikzlings
-%
-% Released under the LaTeX Project Public License v1.3c or later
-% See http://www.latex-project.org/lppl.txt
-%
+%%
+%% This package is part of the TikZlings package
+%% A package to bring cute little animals and other beings into tikz
+%% Maintained by samcarter
+%%
+%% Project repository and bug tracker:
+%% https://github.com/samcarter/tikzlings
+%%
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ProvidesPackage{tikzlings-snowmen}[2021/04/16 version v0.6 Draw snowmen in TikZ]
+\ProvidesPackage{tikzlings-snowmen}[2021/08/06 version v0.8 Draw snowmen in TikZ]
\RequirePackage{tikz}
\RequirePackage{tikzlings-addons}
@@ -76,128 +76,196 @@
}
\def\snowman@draw{%
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ % minimal bounding box size
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \path (-0.75, 0.0) rectangle (0.75, 2.13);
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ % store the current scale factor
+ % from https://github.com/samcarter/tikzlings/issues/3#issuecomment-461373494
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
+ \pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))*sqrt(abs((\pgf@xx/1cm)*(\pgf@yy/1cm)-(\pgf@xy/1cm)*(\pgf@yx/1cm)))}%
+ \pgfmathsetmacro{\xscalefactor}{\tmpscaleA}
+ \pgfmathsetmacro{\yscalefactor}{\tmpscaleD}
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ % switch between 2D, 3D and contours, from
+ % https://chat.stackexchange.com/transcript/message/45991801#45991801
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \ifsnowman@threeD
+ \def\snowman@part@draw[##1]{\shade[ball color=##1]}
+ \else% 3D
+ \ifsnowman@contour
+ \def\snowman@part@draw[##1]{\draw[##1,\snowman@contour,fill=white,line width=\scalingfactor*0.4pt]}
+ \else% contour
+ \def\snowman@part@draw[##1]{\fill[##1]}
+ \fi% contour
+ \fi% 3D
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ % Body parts
+ %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname snowmanhookbackground\endcsname
+ \csname tikzlinghookbackground\endcsname
+ %
+ % Global warming %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \ifsnowman@globalwarming
+ %
+ % Puddle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \ifsnowman@contour
+ \draw[\snowman@contour,fill=white,line width=\scalingfactor*0.4pt] (0,1.15) ellipse[x radius=1.6,y radius=1.15];
+ \else% contour
+ \fill[\snowman@globalwarming] (0,1.15) ellipse[x radius=1.6,y radius=1.15];
+ \fi% contour
+ %
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname snowmanhookbelly\endcsname
+ \csname tikzlinghookbelly\endcsname
+ %
+ % Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \fill[\snowman@mouth] (0,1.23) circle[radius=0.025];
+ \fill[\snowman@mouth] (0.06,1.3) circle[radius=0.025];
+ \fill[\snowman@mouth] (-0.06,1.27) circle[radius=0.025];
+ \fill[\snowman@mouth] (0.09,1.37) circle[radius=0.025];
+ \fill[\snowman@mouth] (-0.18,1.28) circle[radius=0.025];
+ \fill[\snowman@mouth] (0.2,1.28) circle[radius=0.025];
+ \fill[\snowman@mouth] (-0.25,1.2) circle[radius=0.025];
+ %
+ % Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@eye] (-0.5,1.75) circle[radius=0.06];
+ \snowman@part@draw[\snowman@eye] (-0.1,1.55) circle[radius=0.06];
+ %
+ % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@nose] (-0.6,1.4) -- (-0.8,1.42) -- (-0.6,1.54) (-0.6,1.4) arc[radius=0.07, start angle=-90, end angle=90];
+ %
+ % Buttons %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@buttons] (0.1,0.8) circle[radius=0.06];
+ \snowman@part@draw[\snowman@buttons] (-0.15,0.55) circle[radius=0.06];
+ \snowman@part@draw[\snowman@buttons] (0,0.25) circle[radius=0.06];
+ %
+ % normal snowman %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \else% global warming
+ %
+ % Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@body] (0.5,1.1) ellipse[x radius=0.3, y radius=0.12, rotate=-50];
+ \snowman@part@draw[\snowman@body] (-0.5,1.1) ellipse[x radius=0.3, y radius=0.12, rotate=50];
+ %
+ % Body + Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@body] (0,0.5) ellipse[x radius=0.6, y radius=0.5];
+ \snowman@part@draw[\snowman@body] (0,1.1) ellipse[x radius=0.5, y radius=0.4];
+ \snowman@part@draw[\snowman@body] (0,1.7) circle[radius=0.4];
+ %
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname snowmanhookbelly\endcsname
+ \csname tikzlinghookbelly\endcsname
+ %
+ % Show details only from the front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \unless\ifsnowman@back
+ %
+ % Mouth% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \fill[\snowman@mouth] (0,1.5) circle[radius=0.016];
+ \fill[\snowman@mouth] (0.04,1.507) circle[radius=0.016];
+ \fill[\snowman@mouth] (-0.04,1.507) circle[radius=0.016];
+ \fill[\snowman@mouth] (0.08,1.522) circle[radius=0.016];
+ \fill[\snowman@mouth] (-0.08,1.522) circle[radius=0.016];
+ \fill[\snowman@mouth] (0.12,1.543) circle[radius=0.016];
+ \fill[\snowman@mouth] (-0.12,1.543) circle[radius=0.016];
+ %
+ % Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@eye] (-0.155,1.8) circle[radius=0.04];
+ \snowman@part@draw[\snowman@eye] (0.155,1.8) circle[radius=0.04];
+ %
+ % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@nose] (0,1.72) arc [radius=0.05, start angle=90, end angle=270] (0,1.62) -- (0.15,1.64) -- (0,1.72);
+ %
+ % Buttons %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \snowman@part@draw[\snowman@buttons] (0,1.15) circle[radius=0.04];
+ \snowman@part@draw[\snowman@buttons] (0,0.95) circle[radius=0.04];
+ \snowman@part@draw[\snowman@buttons] (0,0.75) circle[radius=0.04];
+ %
+ \fi% back
+ %
+ \fi% global warming
+ %
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname snowmanhookbody\endcsname
+ \csname tikzlinghookbody\endcsname
+ %
+}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% minimal bounding box size
-%
+%%
+%% Documentation
+%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\path (-0.75, 0.0) rectangle (0.75, 2.13);
+%\clearpage
+%\section[Snowman]{Yuki, the snowman}
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%\emph{Yuki is the transcription of the Japanese word for snow}
%
-% store the current scale factor
-% from https://github.com/samcarter/tikzlings/issues/3#issuecomment-461373494
+%\subsection{Package name}
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
-\pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))*sqrt(abs((\pgf@xx/1cm)*(\pgf@yy/1cm)-(\pgf@xy/1cm)*(\pgf@yx/1cm)))}%
-\pgfmathsetmacro{\xscalefactor}{\tmpscaleA}
-\pgfmathsetmacro{\yscalefactor}{\tmpscaleD}
+%\begin{tcolorbox}[lower separated=false, lefthand width=.8\linewidth]
+%\vspace*{0.5cm}
+%\lstinline|\usepackage{tikzlings-snowmen}|
+%\vspace*{0.5cm}
+%\end{tcolorbox}
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% switch between 2D, 3D and contours, from
-% https://chat.stackexchange.com/transcript/message/45991801#45991801
+%\subsection{Basic Usage}
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifsnowman@threeD
- \def\snowman@part@draw[##1]{\shade[ball color=##1]}
-\else
- \ifsnowman@contour
- \def\snowman@part@draw[##1]{\draw[##1,\snowman@contour,fill=white,line width=\scalingfactor*0.4pt]}
- \else
- \def\snowman@part@draw[##1]{\fill[##1]}
- \fi
-\fi
+%\begin{tcblisting}{}
+%\snowman
+%\end{tcblisting}
%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%\subsection{Options}
%
-% Body parts
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%The basic snowman can be modified by changing its colour:
+%\begin{tcblisting}{}
+%\snowman[body=blue]
+%\end{tcblisting}
%
-% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\csname snowmanhookbackground\endcsname
-\csname tikzlinghookbackground\endcsname
+%In addition to the colour of the body, the colour of various body parts can be adjusted:
+%\begin{tcblisting}{}
+%\snowman[eye=red]
+%\end{tcblisting}
+%\begin{tcblisting}{}
+%\snowman[nose=red]
+%\end{tcblisting}
+%\begin{tcblisting}{}
+%\snowman[mouth=red]
+%\end{tcblisting}
+%\begin{tcblisting}{}
+%\snowman[buttons=red]
+%\end{tcblisting}
%
-% Global warming %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ifsnowman@globalwarming
- %
- % Puddle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \ifsnowman@contour
- \draw[\snowman@contour,fill=white,line width=\scalingfactor*0.4pt] (0,1.15) ellipse[x radius=1.6,y radius=1.15];
- \else
- \fill[\snowman@globalwarming] (0,1.15) ellipse[x radius=1.6,y radius=1.15];
- \fi
- %
- % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \csname snowmanhookbelly\endcsname
- \csname tikzlinghookbelly\endcsname
- %
- % Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \fill[\snowman@mouth] (0,1.23) circle[radius=0.025];
- \fill[\snowman@mouth] (0.06,1.3) circle[radius=0.025];
- \fill[\snowman@mouth] (-0.06,1.27) circle[radius=0.025];
- \fill[\snowman@mouth] (0.09,1.37) circle[radius=0.025];
- \fill[\snowman@mouth] (-0.18,1.28) circle[radius=0.025];
- \fill[\snowman@mouth] (0.2,1.28) circle[radius=0.025];
- \fill[\snowman@mouth] (-0.25,1.2) circle[radius=0.025];
- %
- % Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@eye] (-0.5,1.75) circle[radius=0.06];
- \snowman@part@draw[\snowman@eye] (-0.1,1.55) circle[radius=0.06];
- %
- % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@nose] (-0.6,1.4) -- (-0.8,1.42) -- (-0.6,1.54) (-0.6,1.4) arc[radius=0.07, start angle=-90, end angle=90];
- %
- % Buttons %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@buttons] (0.1,0.8) circle[radius=0.06];
- \snowman@part@draw[\snowman@buttons] (-0.15,0.55) circle[radius=0.06];
- \snowman@part@draw[\snowman@buttons] (0,0.25) circle[radius=0.06];
+%The biggest enemy of the snowman are raising temperatures:
+%\begin{tcblisting}{}
+%\snowman[globalwarming,tophat]
+%\end{tcblisting}
%
-% normal snowman %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\else
- %
- % Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@body] (0.5,1.1) ellipse[x radius=0.3, y radius=0.12, rotate=-50];
- \snowman@part@draw[\snowman@body] (-0.5,1.1) ellipse[x radius=0.3, y radius=0.12, rotate=50];
- %
- % Body + Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@body] (0,0.5) ellipse[x radius=0.6, y radius=0.5];
- \snowman@part@draw[\snowman@body] (0,1.1) ellipse[x radius=0.5, y radius=0.4];
- \snowman@part@draw[\snowman@body] (0,1.7) circle[radius=0.4];
- %
- % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \csname snowmanhookbelly\endcsname
- \csname tikzlinghookbelly\endcsname
- %
- % Show details only from the front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \unless\ifsnowman@back
- %
- % Mouth% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \fill[\snowman@mouth] (0,1.5) circle[radius=0.016];
- \fill[\snowman@mouth] (0.04,1.507) circle[radius=0.016];
- \fill[\snowman@mouth] (-0.04,1.507) circle[radius=0.016];
- \fill[\snowman@mouth] (0.08,1.522) circle[radius=0.016];
- \fill[\snowman@mouth] (-0.08,1.522) circle[radius=0.016];
- \fill[\snowman@mouth] (0.12,1.543) circle[radius=0.016];
- \fill[\snowman@mouth] (-0.12,1.543) circle[radius=0.016];
- %
- % Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@eye] (-0.155,1.8) circle[radius=0.04];
- \snowman@part@draw[\snowman@eye] (0.155,1.8) circle[radius=0.04];
- %
- % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@nose] (0,1.72) arc [radius=0.05, start angle=90, end angle=270] (0,1.62) -- (0.15,1.64) -- (0,1.72);
- %
- % Buttons %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \snowman@part@draw[\snowman@buttons] (0,1.15) circle[radius=0.04];
- \snowman@part@draw[\snowman@buttons] (0,0.95) circle[radius=0.04];
- \snowman@part@draw[\snowman@buttons] (0,0.75) circle[radius=0.04];
- %
-\fi\fi
-% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\csname snowmanhookbody\endcsname
-\csname tikzlinghookbody\endcsname
+%To view the snowman from behind:
+%\begin{tcblisting}{}
+%\snowman[back]
+%\end{tcblisting}
%
-}
+%The key \lstinline|3D| will make the snowman 3-dimensional:
+%\begin{tcblisting}{}
+%\snowman[3D]
+%\end{tcblisting}
+%
+%And finally the \lstinline|contour| key will only draw the outlines:
+%\begin{tcblisting}{}
+%\snowman[contour=black]
+%\end{tcblisting}