% !TeX root = ./examples/tikzlings.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This is the main 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
https://www.latex-project.org/lppl.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{tikzlings}[2025/03/23 version v2.3 Collection of packages to draw animals and other beings in TikZ]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% List of all TikZlings
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikzlings-list}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% load sub-packages
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikz}
\ExplSyntaxOn
\cs_new_eq:NN \tikzlings@clistMapInlineNn \clist_map_inline:Nn
\ExplSyntaxOff
\tikzlings@clistMapInlineNn{\tikzlings@packages@clist}{%
\RequirePackage{tikzlings-#1}}
\RequirePackage{tikzlings-addons}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Hooks
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NewHook{tikzlings/background}
\NewHook{tikzlings/body}
\NewHook{tikzlings/clothing}
\NewHook{tikzlings/hair}
\NewHook{tikzlings/hat}
\NewHook{tikzlings/foreground}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Drawing a random tikzling
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\ifdefined\sys_rand_seed:
\pgfmathsetseed {\sys_rand_seed:}
\else
\ifdefined\pdfrandomseed % pdflatex
\else
\ifdefined\randomseed
\let\pdfrandomseed\randomseed % post TL19 xelatex and lualatex
\else
\let\pdfrandomseed\time % pre TL19 xelatex
\fi
\fi
\pgfmathsetseed{\number\pdfrandomseed}
\fi
% #1: tikzling name.
% The second argument of \__tikzlings_show_tikzling:nn will be provided
% by \tikzling.
\cs_new:Npn \__tikzlings_brace_item:n #1
{ { \__tikzlings_show_tikzling:nn {#1} } }
% #1: tikzling name
% #2: options passed to its command
\cs_new_protected:Npn \__tikzlings_show_tikzling:nn #1#2
{
\group_begin:
\pgfkeys
{
/#1/.search~also/.expanded =
{ /tikz, /pgf, /thing, \tikzlings@search@paths@clist }
}
\use:c {#1} [{#2}]
\group_end:
}
\cs_new_protected:Npn \__tikzlings_declare_pgfmath_random_list:n #1
{
\pgfmathdeclarerandomlist { tikzlings } {#1}
}
% Variant that uses \edef on the argument, then passes the result to
% \__tikzlings_declare_pgfmath_random_list:n
\cs_generate_variant:Nn \__tikzlings_declare_pgfmath_random_list:n { x }
% Works because \clist_map_function:NN is expandable
\__tikzlings_declare_pgfmath_random_list:x
{
\clist_map_function:NN \g__tikzlings_names_clist \__tikzlings_brace_item:n
}
\ExplSyntaxOff
\newcommand{\tikzling}[1][]{%
\pgfmathrandomitem{\tikzlings@random}{tikzlings}%
% #1 is passed as second argument to \__tikzlings_show_tikzling:nn
\tikzlings@random{#1}%
}