summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty')
-rw-r--r--graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty77
1 files changed, 49 insertions, 28 deletions
diff --git a/graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty b/graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty
index 206a291895..e4bbb3e515 100644
--- a/graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty
+++ b/graphics/pgf/contrib/tikzlings/tikzlings-koalas.sty
@@ -1,9 +1,8 @@
% !TeX root = ./examples/koala.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% The tikzlings-koalas package (part of the tikzlings collection)
-% A package to bring little koalas into tikz
-% Created by @marmot (https://tex.stackexchange.com/a/448397/36296)
+% 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:
@@ -12,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-koalas}
- [2019/04/07 v0.2 Drawing koalas in TikZ]
+\ProvidesPackage{tikzlings-koalas}[2020/04/22 version v0.3 Drawing koalas in TikZ]
\RequirePackage{tikz}
\RequirePackage{tikzlings-addons}
@@ -32,11 +27,16 @@
\koala@draw%
\end{scope}%
\thing[#1]%
+ % adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \csname koalahookforeground\endcsname
+ \csname tikzlinghookforeground\endcsname
+ %
}
\newif\ifkoala@blush
\newif\ifkoala@sleeping
\newif\ifkoala@threeD
+\newif\ifkoala@back
\tikzset{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -61,6 +61,7 @@
blush/.code = \koala@blushtrue,
sleeping/.code = \koala@sleepingtrue,
3D/.code = \koala@threeDtrue,
+ back/.code = \koala@backtrue,
}
\def\koala@draw{%
@@ -78,7 +79,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}
%
@@ -100,30 +101,45 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname koalahookbackground\endcsname
+\csname tikzlinghookbackground\endcsname
+%
% Feet %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\koala@part@draw[\koala@body!50!black] (0.255,0.2) ellipse (0.23 and 0.09);
-\koala@part@draw[\koala@body!50!black] (-0.255,0.2) ellipse (0.23 and 0.09);
+\koala@part@draw[\koala@body!50!black] (0.255,0.2) ellipse[x radius=0.23, y radius=0.09];
+\koala@part@draw[\koala@body!50!black] (-0.255,0.2) ellipse[x radius=0.23, y radius=0.09];
%
% Ears %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\koala@part@draw[\koala@body] (0.405, 2.1) ellipse (0.3 and 0.23);
-\koala@part@draw[\koala@body!40!white] (0.405, 2.1) ellipse (0.15 and 0.12);
-\koala@part@draw[\koala@body] (-0.405, 2.1) ellipse (0.3 and 0.23);
-\koala@part@draw[\koala@body!40!white] (-0.405, 2.1) ellipse (0.15 and 0.12);
+\koala@part@draw[\koala@body] (0.405, 2.1) ellipse[x radius=0.3, y radius=0.23];
+\koala@part@draw[\koala@body] (-0.405, 2.1) ellipse[x radius=0.3, y radius=0.23];
+\ifkoala@back\else
+ \koala@part@draw[\koala@body!40!white] (-0.405, 2.1) ellipse[x radius=0.15, y radius=0.12];
+ \koala@part@draw[\koala@body!40!white] (0.405, 2.1) ellipse[x radius=0.15, y radius=0.12];
+\fi
%
% Arms %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\koala@part@draw[\koala@body,rotate around={70:(-0.625,1)}] (-0.625,1) ellipse (0.42 and 0.13);
-\koala@part@draw[\koala@body!50!black,rotate around={-20:(-0.745,0.65)}] (-0.745,0.65) ellipse (0.12 and 0.08);
-\koala@part@draw[\koala@body,rotate around={-70:(0.625,1)}] (0.625,1) ellipse (0.42 and 0.13);
-\koala@part@draw[\koala@body!50!black,rotate around={20:(0.745,0.65)}] (0.745,0.65) ellipse (0.12 and 0.08);
+\koala@part@draw[\koala@body] (-0.625,1) ellipse[x radius=0.42, y radius=0.13, rotate=70];
+\koala@part@draw[\koala@body!50!black] (-0.745,0.65) ellipse[x radius=0.12, y radius=0.08, rotate=-20];
+\koala@part@draw[\koala@body] (0.625,1) ellipse[x radius=0.42, y radius=0.13, rotate=-70];
+\koala@part@draw[\koala@body!50!black] (0.745,0.65) ellipse[x radius=0.12, y radius=0.08, rotate=20];
%
% Body %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\koala@part@draw[\koala@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;
%
% Belly %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\koala@part@draw[\koala@body!40!white] ( 0.425, 0.71) .. controls ( 0.425, 0.41) and ( 0.255, 0.27) .. ( 0 , 0.27) .. controls (-0.255, 0.27) and (-0.425, 0.41) .. (-0.425, 0.71) .. controls (-0.425, 1.01) and (-0.255, 1.20) .. ( 0 , 1.20) .. controls ( 0.225, 1.20) and ( 0.425, 1.01) .. ( 0.425, 0.71) -- cycle;
+\ifkoala@back\else
+ \koala@part@draw[\koala@body!40!white] ( 0.425, 0.71) .. controls ( 0.425, 0.41) and ( 0.255, 0.27) .. ( 0 , 0.27) .. controls (-0.255, 0.27) and (-0.425, 0.41) .. (-0.425, 0.71) .. controls (-0.425, 1.01) and (-0.255, 1.20) .. ( 0 , 1.20) .. controls ( 0.225, 1.20) and ( 0.425, 1.01) .. ( 0.425, 0.71) -- cycle;
+\fi
+%
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname koalahookbelly\endcsname
+\csname tikzlinghookbelly\endcsname
%
% Head %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\koala@part@draw[\koala@body] (0,1.67) ellipse (0.55 and 0.45);
+\koala@part@draw[\koala@body] (0,1.67) ellipse[x radius=0.55, y radius=0.45];
+%
+% Show details only from the front %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ifkoala@back\else
%
% Nose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\koala@part@draw[\koala@body!40!black] (-0.1501, 1.5609) .. controls (-0.1784, 1.4833) and (-0.0827, 1.4108) .. ( 0.0000, 1.4108) .. controls ( 0.0827, 1.4108) and ( 0.1784, 1.4833) .. ( 0.1501, 1.5609) .. controls ( 0.1290, 1.6191) and ( 0.1187, 1.6573) .. ( 0.0750, 1.7010) .. controls ( 0.0336, 1.7424) and (-0.0336, 1.7424) .. (-0.0750, 1.7010) .. controls (-0.1187, 1.6573) and (-0.1290, 1.6191) .. (-0.1501, 1.5609) -- cycle;
@@ -143,15 +159,15 @@
\fill[\koala@body!50!black, even odd rule] (0.3331, 1.741) .. controls (0.3331, 1.685) and (0.1737, 1.685) .. (0.1737, 1.741) .. controls (0.1737, 1.848) and (0.3331, 1.848) .. (0.3331, 1.741) -- cycle (0.328, 1.741) .. controls (0.323, 1.705) and (0.184, 1.705) .. (0.179, 1.741) .. controls (0.184, 1.843) and (0.323, 1.843) .. (0.328, 1.741) -- cycle;
\fill[\koala@body!50!black, even odd rule] (-0.3331, 1.741) .. controls (-0.3331, 1.685) and (-0.1737, 1.685) .. (-0.1737, 1.741) .. controls (-0.1737, 1.848) and (-0.3331, 1.848) .. (-0.3331, 1.741) -- cycle (-0.328, 1.741) .. controls (-0.323, 1.705) and (-0.184, 1.705) .. (-0.179, 1.741) .. controls (-0.184, 1.843) and (-0.323, 1.843) .. (-0.328, 1.741) -- cycle;
\else
- \koala@part@draw[black] (-0.255, 1.74) circle (0.08);
- \koala@part@draw[black] (0.255, 1.74) circle (0.08);
- \fill[white] (-0.27, 1.76) circle (0.015);
- \fill[white] (0.24, 1.76) circle (0.015);
+ \koala@part@draw[black] (-0.255, 1.74) circle[radius=0.08];
+ \koala@part@draw[black] (0.255, 1.74) circle[radius=0.08];
+ \fill[white] (-0.27, 1.76) circle[radius=0.015];
+ \fill[white] (0.24, 1.76) circle[radius=0.015];
\fi
%
% Mouth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifkoala@threeD
- \draw[black,line width=\scalingfactor*0.4pt] (0.115, 1.39) arc [start angle=-40, end angle=-140, radius=0.16];
+ \draw[black,line width=\scalingfactor*0.4pt] (0.115, 1.39) arc [start angle=-40, end angle=-140, radius=0.16];
\else
\draw[\koala@body!40!black,line width=\scalingfactor*0.4pt] (0.115, 1.39) arc [start angle=-40, end angle=-140, radius=0.16];
\fi
@@ -164,9 +180,14 @@
%
% Blushed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifkoala@blush
- \fill[red,path fading=koala@blush] (-0.3, 1.52) circle (0.1);
- \fill[red,path fading=koala@blush] (0.3, 1.52) circle (0.1);
+ \fill[red,path fading=koala@blush] (-0.3, 1.52) circle[radius=0.1];
+ \fill[red,path fading=koala@blush] (0.3, 1.52) circle[radius=0.1];
+\fi
+%
\fi
+% adding hook for users to customise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\csname koalahookbody\endcsname
+\csname tikzlinghookbody\endcsname
%
}