diff options
Diffstat (limited to 'graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty')
-rw-r--r-- | graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty | 112 |
1 files changed, 68 insertions, 44 deletions
diff --git a/graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty b/graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty index d551f0a060..13845d8671 100644 --- a/graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty +++ b/graphics/pgf/contrib/tikzlings/tikzlings-pigs.sty @@ -9,14 +9,14 @@ %% https://github.com/samcarter/tikzlings %% %% Released under the LaTeX Project Public License v1.3c or later -%% See http://www.latex-project.org/lppl.txt +%% See https://www.latex-project.org/lppl.txt %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ProvidesPackage{tikzlings-pigs}[2022/06/17 version v1.0 Drawing pigs in TikZ] +\ProvidesPackage{tikzlings-pigs}[2025/01/05 version v2.2 Drawing pigs in TikZ] \RequirePackage{tikz} \RequirePackage{tikzlings-addons} -\definecolor{pigdark}{RGB}{241,164,142} +\definecolor{piglight}{RGB}{247,205,193} \newcommand*{\pig}[1][]{% \begin{scope}% @@ -27,12 +27,13 @@ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \csname pighookforeground\endcsname \csname tikzlinghookforeground\endcsname - % + % } \newif\ifpig@threeD \newif\ifpig@back \newif\ifpig@contour +\newif\ifpig@openmouth \tikzset{ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -48,11 +49,11 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% body/.store in = \pig@body, - body = pigdark, + body = piglight, eye/.store in = \pig@eye, - eye = gray, + eye = gray, tail/.store in = \pig@tail, - tail = \pig@body, + tail = pig@bodysat22, mouth/.store in = \pig@mouth, mouth = gray, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -60,21 +61,23 @@ % options % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + openmouth/.code = \pig@openmouthtrue, + open mouth/.forward to = /pig/openmouth, 3D/.code = \pig@threeDtrue - \def\pig@mouth{gray!70!black}, - back/.code = \pig@backtrue, + \def\pig@mouth{gray!70!black}, + back/.code = \pig@backtrue, contour/.code = \pig@contourtrue \def\pig@contour{#1} \def\pig@mouth{#1} \def\pig@tail{#1}, - contour/.default = black, - outline/.forward to = /pig/contour, + contour/.default = black, + outline/.forward to = /pig/contour, } \def\pig@draw{% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - % minimal bounding box size + % minimal bounding box size % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \path (-0.625,0.1) rectangle (0.905, 2.27); @@ -91,7 +94,7 @@ \pgfmathsetmacro{\yscalefactor}{\tmpscaleD} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % + % % switch between 2D, 3D and contours, from % https://chat.stackexchange.com/transcript/message/45991801#45991801 % @@ -108,8 +111,20 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % + % generating saturated version of body colour + % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \extractcolorspecs{\pig@body}{\pig@model}{\pig@colorspec} + \convertcolorspec{\pig@model}{\pig@colorspec}{hsb}{\pig@hsbcolorspec} + \pgfmathsetmacro{\pig@hue}{(array({\pig@hsbcolorspec},0))} + \pgfmathsetmacro{\pig@sat}{(array({\pig@hsbcolorspec},1)+0.22)} + \pgfmathsetmacro{\pig@bright}{(array({\pig@hsbcolorspec},2))} + \definecolor{pig@bodysat22}{hsb}{\pig@hue,\pig@sat,\pig@bright} + % + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % % Body parts - % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -123,12 +138,12 @@ % % Feet if back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifpig@back - \pig@part@draw[\pig@body] (0.3216,0.15) arc (-15:195:0.12) -- (0.16,0.15) to [bend left] (0.25,0.15) -- cycle; - \pig@part@draw[\pig@body] (-0.3216,0.15) arc (195:-15:0.12) -- (-0.16,0.15) to[bend right] (-0.25,0.15) --cycle; + \pig@part@draw[pig@bodysat22] (0.3216,0.15) arc (-15:195:0.12) -- (0.16,0.15) to [bend left] (0.25,0.15) -- cycle; + \pig@part@draw[pig@bodysat22] (-0.3216,0.15) arc (195:-15:0.12) -- (-0.16,0.15) to[bend right] (-0.25,0.15) --cycle; \fi% back % % Body %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \pig@part@draw[\pig@body!55!white] ( 0.6, 0.8 ) .. controls ( 0.6 , 0.4) and ( 0.35, 0.16) .. ( 0.0, 0.16) .. controls (-0.35, 0.16) and (-0.6 , 0.4) .. (-0.6, 0.8 ) .. controls (-0.6 , 1.3) and (-0.35, 1.5) .. ( 0.0, 1.5) .. controls ( 0.35, 1.5) and ( 0.6 , 1.3) .. ( 0.6, 0.75) -- cycle; + \pig@part@draw[\pig@body] ( 0.6, 0.8 ) .. controls ( 0.6 , 0.4) and ( 0.35, 0.16) .. ( 0.0, 0.16) .. controls (-0.35, 0.16) and (-0.6 , 0.4) .. (-0.6, 0.8 ) .. controls (-0.6 , 1.3) and (-0.35, 1.5) .. ( 0.0, 1.5) .. controls ( 0.35, 1.5) and ( 0.6 , 1.3) .. ( 0.6, 0.75) -- cycle; % % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \csname pighookbelly\endcsname @@ -136,12 +151,12 @@ % % Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \unless\ifpig@back - \pig@part@draw[\pig@body] (-0.2402, 0.9823) .. controls (-0.2994, 1.0582) and (-0.3721, 1.0651) .. (-0.4024, 0.9978) .. controls (-0.4327, 0.9305) and (-0.4092, 0.8145) .. (-0.35, 0.7386) .. controls (-0.3311, 0.7145) and (-0.3101, 0.6964) .. (-0.289, 0.6862) .. controls (-0.2755, 0.7023) and (-0.2498, 0.7563) .. (-0.2498, 0.7563) .. controls (-0.2498, 0.7563) and (-0.1790, 0.731) .. (-0.1611, 0.746) .. controls (-0.1611, 0.746) and (-0.1809, 0.9064) .. (-0.2402, 0.9823) -- cycle; - \pig@part@draw[\pig@body] (0.2402, 0.9823) .. controls (0.2994, 1.0582) and (0.3721, 1.0651) .. (0.4024, 0.9978) .. controls (0.4327, 0.9305) and (0.4092, 0.8145) .. (0.35, 0.7386) .. controls (0.3311, 0.7145) and (0.3101, 0.6964) .. (0.289, 0.6862) .. controls (0.2755, 0.7023) and (0.2498, 0.7563) .. (0.2498, 0.7563) .. controls (0.2498, 0.7563) and (0.1790, 0.731) .. (0.1611, 0.746) .. controls (0.1611, 0.746) and (0.1809, 0.9064) .. (0.2402, 0.9823) -- cycle; + \pig@part@draw[pig@bodysat22] (-0.2402, 0.9823) .. controls (-0.2994, 1.0582) and (-0.3721, 1.0651) .. (-0.4024, 0.9978) .. controls (-0.4327, 0.9305) and (-0.4092, 0.8145) .. (-0.35, 0.7386) .. controls (-0.3311, 0.7145) and (-0.3101, 0.6964) .. (-0.289, 0.6862) .. controls (-0.2755, 0.7023) and (-0.2498, 0.7563) .. (-0.2498, 0.7563) .. controls (-0.2498, 0.7563) and (-0.1790, 0.731) .. (-0.1611, 0.746) .. controls (-0.1611, 0.746) and (-0.1809, 0.9064) .. (-0.2402, 0.9823) -- cycle; + \pig@part@draw[pig@bodysat22] (0.2402, 0.9823) .. controls (0.2994, 1.0582) and (0.3721, 1.0651) .. (0.4024, 0.9978) .. controls (0.4327, 0.9305) and (0.4092, 0.8145) .. (0.35, 0.7386) .. controls (0.3311, 0.7145) and (0.3101, 0.6964) .. (0.289, 0.6862) .. controls (0.2755, 0.7023) and (0.2498, 0.7563) .. (0.2498, 0.7563) .. controls (0.2498, 0.7563) and (0.1790, 0.731) .. (0.1611, 0.746) .. controls (0.1611, 0.746) and (0.1809, 0.9064) .. (0.2402, 0.9823) -- cycle; \fi% back % % Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \pig@part@draw[\pig@body!55!white] (0,1.64) ellipse[x radius=.5, y radius=.5]; + \pig@part@draw[\pig@body] (0,1.64) ellipse[x radius=.5, y radius=.5]; % % Show details only from the front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \unless\ifpig@back @@ -151,28 +166,32 @@ \pig@part@draw[\pig@eye] ( 0.09, 1.82) circle[radius=0.02]; % % Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \pig@part@draw[\pig@body] (0, 1.62) ellipse[x radius=0.18, y radius=0.14]; + \pig@part@draw[pig@bodysat22] (0, 1.62) ellipse[x radius=0.18, y radius=0.14]; \pig@part@draw[gray] (-0.06, 1.62) circle[radius=0.035]; \pig@part@draw[gray] ( 0.06, 1.62) circle[radius=0.035]; % % Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \draw[\pig@mouth,line width=\scalingfactor*0.4pt] (0.105, 1.46) arc [start angle=-50, end angle=-130, radius=0.16] ; + \ifpig@openmouth + \filldraw[\pig@mouth,line width=\scalingfactor*0.4pt] (0.105, 1.46) arc [start angle=-50, end angle=-130, radius=0.16]; + \else + \draw[\pig@mouth,line width=\scalingfactor*0.4pt] (0.105, 1.46) arc [start angle=-50, end angle=-130, radius=0.16]; + \fi % % Feet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \pig@part@draw[\pig@body] (0.3216,0.15) arc (-15:195:0.12) -- (0.16,0.15) to [bend left] (0.25,0.15) -- cycle; - \pig@part@draw[\pig@body] (-0.3216,0.15) arc (195:-15:0.12) -- (-0.16,0.15) to[bend right] (-0.25,0.15) --cycle; + \pig@part@draw[pig@bodysat22] (0.3216,0.15) arc (-15:195:0.12) -- (0.16,0.15) to [bend left] (0.25,0.15) -- cycle; + \pig@part@draw[pig@bodysat22] (-0.3216,0.15) arc (195:-15:0.12) -- (-0.16,0.15) to[bend right] (-0.25,0.15) --cycle; % \fi% back % % Ears %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \pig@part@draw[\pig@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; - \pig@part@draw[\pig@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; - \pig@part@draw[\pig@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; - \pig@part@draw[\pig@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; - % + \pig@part@draw[pig@bodysat22] (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; + \pig@part@draw[\pig@body] (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; + \pig@part@draw[pig@bodysat22] (-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; + \pig@part@draw[\pig@body] (-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; + % % Tail if back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifpig@back - \draw[\pig@tail,line width=\scalingfactor*0.8pt] (0.8431, 0.583) .. controls (0.8609, 0.4063) and (0.7006, 0.361) .. (0.6384, 0.4293) .. controls (0.5762, 0.4976) and (0.5613, 0.6052) .. (0.6551, 0.629) .. controls (0.7537, 0.6541) and (0.7759, 0.5628) .. (0.7455, 0.4948) .. controls (0.6412, 0.2697) and (0.3543, 0.356) .. (0.2638, 0.4238) .. controls (0.1967, 0.4779) and (0.1788, 0.6076) .. (0.3192, 0.633) .. controls (0.6000, 0.6836) and (0.5130, 0.3048) .. (0.2098, 0.3322) .. controls (0.0809, 0.3438) and (0.0809, 0.5236) .. (0.0809, 0.5236); + \draw[\pig@tail,line width=\scalingfactor*0.8pt] (0.8431, 0.583) .. controls (0.8609, 0.4063) and (0.7006, 0.361) .. (0.6384, 0.4293) .. controls (0.5762, 0.4976) and (0.5613, 0.6052) .. (0.6551, 0.629) .. controls (0.7537, 0.6541) and (0.7759, 0.5628) .. (0.7455, 0.4948) .. controls (0.6412, 0.2697) and (0.3543, 0.356) .. (0.2638, 0.4238) .. controls (0.1967, 0.4779) and (0.1788, 0.6076) .. (0.3192, 0.633) .. controls (0.6000, 0.6836) and (0.5130, 0.3048) .. (0.2098, 0.3322) .. controls (0.0809, 0.3438) and (0.0809, 0.5236) .. (0.0809, 0.5236); \fi% back % % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -193,47 +212,52 @@ % %\subsection{Package name} % -%\begin{tcolorbox}[lower separated=false, lefthand width=.8\linewidth] -%\vspace*{0.5cm} -%\lstinline|\usepackage{tikzlings-pigs}| -%\vspace*{0.5cm} +%\begin{tcolorbox}[title={Package usage}] +%\begin{samcode} +%\usepackage{tikzlings-pigs} +%\end{samcode} %\end{tcolorbox} % %\subsection{Basic Usage} % -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Basic pig}} %\pig %\end{tcblisting} % %\subsection{Options} % %The basic pig can be modified by changing its colour: -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Body colour}} %\pig[body=blue] %\end{tcblisting} % %In addition to the colour of the body, the colour of various body parts can be adjusted: -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Eye colour}} %\pig[eye=red] %\end{tcblisting} -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Tail colour}} %\pig[tail=red] %\end{tcblisting} -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Mouth colour}} %\pig[mouth=red] %\end{tcblisting} % +% The pig can open its mouth: +%\begin{tcblisting}{title={Open mouth}} +%\pig[openmouth] +%\end{tcblisting} +% %To view the pig from behind: -%\begin{tcblisting}{} +%\begin{tcblisting}{title={Back view}} %\pig[back] %\end{tcblisting} % -%The key \lstinline|3D| will make the pig 3-dimensional: -%\begin{tcblisting}{} +%The key \saminline|3D| will make the pig 3-dimensional: +%\begin{tcblisting}{title={3D view}} %\pig[3D] %\end{tcblisting} % -%And finally the \lstinline|contour| key will only draw the outlines: -%\begin{tcblisting}{} +%And finally the \saminline|contour| key will only draw the outlines: +%\begin{tcblisting}{title={Contours}} %\pig[contour=black] %\end{tcblisting} |