summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty')
-rw-r--r--graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty104
1 files changed, 69 insertions, 35 deletions
diff --git a/graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty b/graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty
index 61d7eb7aeb..8f42d1196a 100644
--- a/graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty
+++ b/graphics/pgf/contrib/tikzlings/tikzlings-hippos.sty
@@ -1,8 +1,8 @@
% !TeX root = ./examples/hippo.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% The tikzlings-hippos package (part of the tikzlings collection)
-% A package to bring little hippos into tikz
+% 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:
@@ -11,12 +11,8 @@
% Released under the LaTeX Project Public License v1.3c or later
% See http://www.latex-project.org/lppl.txt
%
-% Version 0.2
-% April 7, 2019
-%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ProvidesPackage{tikzlings-hippos}
- [2019/04/07 v0.2 Drawing hippos in TikZ]
+\ProvidesPackage{tikzlings-hippos}[2020/04/22 version v0.3 Drawing hippos in TikZ]
\RequirePackage{tikz}
\RequirePackage{tikzlings-addons}
@@ -27,9 +23,13 @@
\hippo@draw%
\end{scope}%
\thing[#1]%
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname hippohookforeground\endcsname
+ \csname tikzlinghookforeground\endcsname
}
\newif\ifhippo@threeD
+\newif\ifhippo@back
\tikzset{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -54,6 +54,7 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3D/.code = \hippo@threeDtrue,
+ back/.code = \hippo@backtrue,
}
\def\hippo@draw{%
@@ -71,7 +72,7 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
-\pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))}%
+\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}
%
@@ -93,49 +94,82 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname hippohookbackground\endcsname
+\csname tikzlinghookbackground\endcsname
+%
% Ears %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\hippo@part@draw[\hippo@body,rotate around={-30:(0.23,2.03)}] (0.23,2.03) ellipse (0.09 and 0.13);
-\hippo@part@draw[\hippo@body,rotate around={30:(-0.23,2.03)}] (-0.23,2.03) ellipse (0.09 and 0.13);
+\hippo@part@draw[\hippo@body] (0.23,2.03) ellipse[x radius=0.09, y radius=0.13, rotate=-30];
+\hippo@part@draw[\hippo@body] (-0.23,2.03) ellipse[x radius=0.09, y radius=0.13, rotate=30];
+%
+% Feet if back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifhippo@back
+ \begin{scope}
+ \clip (-0.5,0.4) rectangle (0.5,0.13);
+ \hippo@part@draw[\hippo@body] (-0.25,0.15) ellipse[x radius=0.16, y radius=0.17];
+ \hippo@part@draw[\hippo@body] (0.25,0.15) ellipse[x radius=0.16, y radius=0.17];
+ \end{scope}
+\fi
+%
+% Nose if back %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifhippo@back
+ \hippo@part@draw[\hippo@body!80!white] (0, 1.55) ellipse[x radius=0.42, y radius=0.2];
+\fi
%
% Body %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\hippo@part@draw[\hippo@body!55!white] ( 0.6, 0.8 ) .. controls ( 0.6 , 0.4) and ( 0.35, 0.19) .. ( 0.0, 0.19) .. controls (-0.35, 0.19) and (-0.6 , 0.4) .. (-0.6, 0.8 ) .. controls (-0.6 , 1.3) and (-0.35, 1.65) .. ( 0.0, 1.65) .. controls ( 0.35, 1.65) and ( 0.6 , 1.3) .. ( 0.6, 0.8) -- cycle;
%
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname hippohookbelly\endcsname
+\csname tikzlinghookbelly\endcsname
+%
% Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\hippo@part@draw[\hippo@body,rotate around={90:(0.35,1.0)}] (0.35,1.0) ellipse (0.24 and 0.13);
-\hippo@part@draw[\hippo@body,rotate around={-90:(-0.35,1.0)}] (-0.35,1.0) ellipse (0.24 and 0.13);
+\ifhippo@back\else
+ \hippo@part@draw[\hippo@body] (0.35,1.0) ellipse[x radius=0.24, y radius=0.13, rotate=90];
+ \hippo@part@draw[\hippo@body] (-0.35,1.0) ellipse[x radius=0.24, y radius=0.13, rotate=-90];
+\fi
%
% Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\hippo@part@draw[\hippo@body!55!white] (0, 1.76) circle (0.36);
+\hippo@part@draw[\hippo@body!55!white] (0, 1.76) circle[radius=0.36];
+%
+% Show details only from the front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifhippo@back\else
%
% Eyes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\fill[white] (-0.11, 1.83) ellipse (0.08 and 0.12);
-\fill[white] (0.11, 1.83) ellipse (0.08 and 0.12);
-\fill[black] (-0.105, 1.78) ellipse (0.04 and 0.07);
-\fill[black] (0.105, 1.78) ellipse (0.04 and 0.07);
+\fill[white] (-0.11, 1.83) ellipse[x radius=0.08, y radius=0.12];
+\fill[white] (0.11, 1.83) ellipse[x radius=0.08, y radius=0.12];
+\fill[black] (-0.105, 1.78) ellipse[x radius=0.04, y radius=0.07];
+\fill[black] (0.105, 1.78) ellipse[x radius=0.04, y radius=0.07];
%
% Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\hippo@part@draw[\hippo@body!80!white] (0, 1.55) ellipse (0.42 and 0.2);
-\hippo@part@draw[\hippo@body!70!black] (-0.07, 1.63) circle (0.035);
-\hippo@part@draw[\hippo@body!70!black] (0.07, 1.63) circle (0.035);
+\hippo@part@draw[\hippo@body!80!white] (0, 1.55) ellipse[x radius=0.42, y radius=0.2];
+\hippo@part@draw[\hippo@body!70!black] (-0.07, 1.63) circle[radius=0.035];
+\hippo@part@draw[\hippo@body!70!black] (0.07, 1.63) circle[radius=0.035];
%
% Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifhippo@threeD
- \draw[black,line width=\scalingfactor*0.4pt] (0.125, 1.5) arc [start angle=-50, end angle=-130, radius=0.2] ;
- \else
- \draw[\hippo@body!70!black,line width=\scalingfactor*0.4pt] (0.125, 1.5) arc [start angle=-50, end angle=-130, radius=0.2] ;
- \fi
- %
+ \draw[black,line width=\scalingfactor*0.4pt] (0.125, 1.5) arc [start angle=-50, end angle=-130, radius=0.2] ;
+\else
+ \draw[\hippo@body!70!black,line width=\scalingfactor*0.4pt] (0.125, 1.5) arc [start angle=-50, end angle=-130, radius=0.2];
+\fi
+%
% Feet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}
- \clip (-0.5,0.4) rectangle (0.5,0.13);
- \hippo@part@draw[\hippo@body] (-0.25,0.15) ellipse (0.16 and 0.17);
- \hippo@part@draw[\hippo@body] (0.25,0.15) ellipse (0.16 and 0.17);
- \hippo@part@draw[\hippo@toes] (0.25,0.13) ellipse (0.05 and 0.1);
- \hippo@part@draw[\hippo@toes] (0.13,0.11) ellipse (0.05 and 0.1);
- \hippo@part@draw[\hippo@toes] (0.37,0.11) ellipse (0.05 and 0.1);
- \hippo@part@draw[\hippo@toes] (-0.25,0.13) ellipse (0.05 and 0.1);
- \hippo@part@draw[\hippo@toes] (-0.13,0.11) ellipse (0.05 and 0.1);
- \hippo@part@draw[\hippo@toes] (-0.37,0.11) ellipse (0.05 and 0.1);
+ \clip (-0.5,0.4) rectangle (0.5,0.13);
+ \hippo@part@draw[\hippo@body] (-0.25,0.15) ellipse[x radius=0.16, y radius=0.17];
+ \hippo@part@draw[\hippo@body] (0.25,0.15) ellipse[x radius=0.16, y radius=0.17];
+ \hippo@part@draw[\hippo@toes] (0.25,0.13) ellipse[x radius=0.05, y radius=0.1];
+ \hippo@part@draw[\hippo@toes] (0.13,0.11) ellipse[x radius=0.05, y radius=0.1];
+ \hippo@part@draw[\hippo@toes] (0.37,0.11) ellipse[x radius=0.05, y radius=0.1];
+ \hippo@part@draw[\hippo@toes] (-0.25,0.13) ellipse[x radius=0.05, y radius=0.1];
+ \hippo@part@draw[\hippo@toes] (-0.13,0.11) ellipse[x radius=0.05, y radius=0.1];
+ \hippo@part@draw[\hippo@toes] (-0.37,0.11) ellipse[x radius=0.05, y radius=0.1];
\end{scope}
%
-} \ No newline at end of file
+\fi
+%
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname hippohookbody\endcsname
+\csname tikzlinghookbody\endcsname
+%
+}