%% Copyright 2016 Nils Fleischhacker
%%
%% This work may be distributed and/or modified under the 
%% conditions of the LaTeX Project Public License, either 
%% version 1.3 of this license or (at your option) any later 
%% version. The latest version of this license is in
%%
%%   http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of 
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Nils Fleischhacker.
\tikzpeople@addcolorkey{details}
\tikzpeople@addcolorkey{pattern}

\newcommand{\tikzpeople@jester@paint}{
	{
		\tikzpeople@person@paintrighthorn
	}
	\tikzpeople@person@paintshirt
	\tikzpeople@jester@paintshirtdetails
	\tikzpeople@person@painthead
	\tikzpeople@person@paintgoatee
	\tikzpeople@person@painthair
	\tikzpeople@jester@painthat
	{
		\tikzpeople@person@paintlefthorn
	}
	\tikzpeople@person@painthalo
}

\newcommand{\tikzpeople@jester@paintshirtdetails}{
	\begin{scope}
		\clip 
		(-4pt,-8pt) .. controls (-2pt,-10pt) and (3pt,-9pt) .. 
		( 5pt,-7pt) .. controls ( 5pt,  0pt) and (-5pt,0pt) ..
		(-4pt,-8pt);
		\coordinate (tikzpeople@tmp) at (2pt,.4pt);
		\path  (-10.5pt,-4pt)coordinate (tikzpeople@tmp1)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp2) ++(tikzpeople@tmp) coordinate (tikzpeople@tmp3)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp4)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp5)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp6)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp7)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp8)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp9)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp10)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp11);
		\path  (-7pt,-12pt) coordinate (tikzpeople@tmp12)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp13) ++(tikzpeople@tmp) coordinate (tikzpeople@tmp14)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp15)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp16) ++(tikzpeople@tmp) coordinate (tikzpeople@tmp17)	++(tikzpeople@tmp) coordinate (tikzpeople@tmp18)
			++(tikzpeople@tmp) coordinate (tikzpeople@tmp19) ++(tikzpeople@tmp) coordinate (tikzpeople@tmp20);
		\fill[pattern] (tikzpeople@tmp2)
			to[in=100,out=300] (tikzpeople@tmp13) to[in=260,out=50] (tikzpeople@tmp6) to[in=100,out=300] (tikzpeople@tmp17)
			to[in=260,out=50] (tikzpeople@tmp10)	-- (tikzpeople@tmp11) to[in=50,out=260] (tikzpeople@tmp18)
			to[in=300,out=100] (tikzpeople@tmp7) to[in=50,out=260] (tikzpeople@tmp14) to[in=300,out=100] (tikzpeople@tmp3) -- 
			(tikzpeople@tmp4) to[in=100,out=300] (tikzpeople@tmp15) to[in=260,out=50] (tikzpeople@tmp8) 
			to[in=100,out=300] (tikzpeople@tmp19) -- (tikzpeople@tmp20)	to[in=300,out=100] (tikzpeople@tmp9)
			to[in=50,out=260] (tikzpeople@tmp16) to[in=300,out=100] (tikzpeople@tmp5) to[in=50,out=260](tikzpeople@tmp12)
			to[in=300,out=100](tikzpeople@tmp1) --cycle;
	\end{scope}
}

\newcommand{\tikzpeople@jester@painthat}{
	\begin{scope}
		\pgftransformrotate{10}
		\draw[hat] 
			(180:3.2pt) to[out=60,in=60] ++(91:3pt) to[out=240,in=90] ++(271:.9pt) 
			to[out=270,in=85] ++(268:.9pt) coordinate (tikzpeople@tmp1) to[out=130,in=170] 
			++(73:4pt) to[out=350,in=180] (.5pt,3.3pt) to[out=0,in=200] ++(45:2.5pt) 
			to[out=20,in=80] ++(290:4pt) coordinate (tikzpeople@tmp2) to[out=100,in=75] 
			++(120:2.1pt) to[out=255,in=100] (0:3.1pt) to[out=170,in=10] (180:3.1pt);
		\path[pattern]
			(0:3.2pt) ++(0,-.2pt) to[out=170,in=10] ++(180:6.4pt) to[out=110,in=250] 
			++(0,1.2pt) to[out=10,in=170] ++(0:6.4pt) to[out=290,in=70] ++(0,-1.22pt)
			--cycle;
		\begin{scope}
			\clip (tikzpeople@tmp1) circle (.4pt) (tikzpeople@tmp2) circle (.4pt);
			\path[details] (tikzpeople@tmp1) ++(-.15pt,.15pt) circle (.7pt);
			\path[details] (tikzpeople@tmp2) ++(-.15pt,.15pt) circle (.7pt);
		\end{scope}
	\end{scope}
}

\newcommand{\tikzpeople@jester@definecolors}{
	\definecolor{shirt}{RGB}{100,187,41}
	\definecolor{pattern}{RGB}{208,48,0}
	\definecolor{hat}{RGB}{100,187,41}
	\definecolor{details}{RGB}{225,87,0}
}
\newcommand{\tikzpeople@jester@definestyles}{
	\if@tikzpeople@saturated
		\tikzset{
			pattern/.style={color=\tikzpeople@pattern,top color=\tikzpeople@pattern!70, bottom color=\tikzpeople@pattern,shading angle=45},
			details/.style={color=\tikzpeople@details,inner color=\tikzpeople@details!50, outer color=\tikzpeople@details}
		}
	\else
		\tikzset{
			pattern/.style={color=\tikzpeople@pattern!80,top color=\tikzpeople@pattern!40, bottom color=\tikzpeople@pattern!80,shading angle=45},
			details/.style={color=\tikzpeople@details,inner color=\tikzpeople@details!30, outer color=\tikzpeople@details!90}
		}
	\fi
}

\newcommand{\tikzpeople@jester@colors}{
	shirt/200/{-1/-1}, hat/40/{.7/1.9}, skin/20/{.6/.9}, 
	details/150/{.85/1.45,-1.05/1.1}, pattern/0/{-.4/1.1,.9/-.2}, 
	hair/180/{-.6/.75}%
}
