%% 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{hairshadow}

\newcommand{\tikzpeople@judge@paint}{
	\tikzpeople@person@paintrighthorn
	\tikzpeople@judge@paintlefthair
	\tikzpeople@person@paintshirt
	\tikzpeople@judge@paintundershirt
	\tikzpeople@person@painthead
	\tikzpeople@judge@paintrighthair
	\tikzpeople@person@paintgoatee
	\tikzpeople@person@paintlefthorn
	\tikzpeople@person@painthalo
}

\newcommand{\tikzpeople@judge@definecolors}{
	\definecolor{shirt}{RGB}{0,0,0}
	\definecolor{undershirt}{rgb}{0.9,0.9,0.9}
	\definecolor{hair}{RGB}{204,161,107}
	\definecolor{hairshadow}{RGB}{186, 137, 55}
}

\newcommand{\tikzpeople@judge@definestyles}{
	\if@tikzpeople@saturated
		\tikzset{
			hairshadow/.style={color=\tikzpeople@hairshadow}
		}
	\else
		\tikzset{
			hairshadow/.style={color=\tikzpeople@hairshadow}
		}
	\fi
}

\newcommand{\tikzpeople@judge@paintlefthair}{
	\draw[hair,join=bevel, shading angle=45] 
		(25:2.7pt) to[out=330,in=80,out looseness=.5] (3.3pt,-3pt) -- (2pt,-3pt); 
	\path[postaction={decorate},decoration={
		markings,
		mark=between positions 0.03 and 1 step .76pt*\scalingfactor with {\pgftransformscale{\scalingfactor}
		\if@tikzpeople@mirrored
			\pgftransformyscale{-1}
		\fi
		\path[fill=\tikzpeople@hairshadow] 
			(.39pt,-.06pt) ellipse 
			(.39pt and .27pt + 0.02*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number});
		\path[fill=\tikzpeople@hair\if@tikzpeople@saturated!80\else!50\fi,draw=\tikzpeople@hairshadow] 
			(.39pt,0pt) ellipse 
			(.39pt and .27pt +0.02*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}); 
		}
	}] (25:2.7pt) to[out=320,in=80,out looseness=.5] (3.3pt,-3pt);
}

\newcommand{\tikzpeople@judge@paintrighthair}{
	\fill[hairshadow] 
		(10:3.05pt) arc (10:135:3.05pt) -- (-1pt,.4pt) 
		to[out=60,in=160,out looseness=1.4] (.9pt,1pt) 
		to[out=40,in=95,out looseness=1.4] (10:3.05pt);
	\path[decorate, decoration={markings,
		mark=at position .165 with {\coordinate (tikzpeople@tmp1) at (0,\if@tikzpeople@mirrored -1*\fi\scalingfactor*.2pt);},
		mark=at position .330 with {\coordinate (tikzpeople@tmp2) at (0,\if@tikzpeople@mirrored -1*\fi\scalingfactor*.2pt);},
		mark=at position .495 with {\coordinate (tikzpeople@tmp3) at (0,\if@tikzpeople@mirrored -1*\fi\scalingfactor*.2pt);},
		mark=at position .660 with {\coordinate (tikzpeople@tmp4) at (0,\if@tikzpeople@mirrored -1*\fi\scalingfactor*.2pt);},
		mark=at position .825 with {\coordinate (tikzpeople@tmp5) at (0,\if@tikzpeople@mirrored -1*\fi\scalingfactor*.2pt);},
	}] (150:3.1pt) to[out=240,in=120,in looseness=.3] (220:4.8pt);
	\draw[hair,join=bevel, shading angle=-45, postaction={decorate},decoration={
		markings,
		mark=between positions 0.614 and 0.82 step .84pt*\scalingfactor with {
			\pgftransformscale{\scalingfactor}
			\if@tikzpeople@mirrored
				\pgftransformyscale{-1}
			\fi
			\fill[\tikzpeople@hairshadow] 
				(-.06pt,0) to[out=70,in=190+2*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number},out looseness=.8] 
				++(46.5+2*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}:3.7pt-.27pt*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) 
				to[out=190+2*\pgfkeysvalueof{/pgf/decoration/mark info/sequence number},in=70,in looseness=.8] (.05pt,0);
			\path[fill=\tikzpeople@hairshadow] (.33pt,0pt) circle (.43pt); 
			\path[fill=\tikzpeople@hair\if@tikzpeople@saturated!80\else!50\fi,draw=\tikzpeople@hairshadow]
				(.31pt,-.025pt) circle (.37pt); 
		}
	}] (10:3pt) to[out=90,in=300] (30:3.1pt) arc (30:150:3.1pt) to[out=190,in=140] (tikzpeople@tmp1)
		to[out=150,in=135] (tikzpeople@tmp2) to[out=155,in=140] (tikzpeople@tmp3) to[out=160,in=145] (tikzpeople@tmp4) 
		to[out=165,in=150] (tikzpeople@tmp5)	to[out=170,in=120] (220:4.8pt) to [out=300,in=160,out looseness=1]	(260:4.8pt) 
		to [out=100,in=260,out looseness=1] (-1pt,.6pt) to [out=80,in=160,out looseness=1.4] (.9pt,1.4pt) 
		to [out=40,in=92,in looseness=1.1,out looseness=1.6] (10:3pt) -- cycle;
}

\newcommand{\tikzpeople@judge@paintundershirt}{
	\begin{scope}
		\draw[undershirt] (320:3pt) to[out=320,in=0, out looseness=1.5] (295:6.8pt)
			to[out=290,in=310,looseness=1.3] ++(-1.1pt,-.7pt) 
			to[out=250,in=300,looseness=1.4] ++(-1.2pt,-.2pt)
			to[out=220,in=280,looseness=1.4] ++(-1.2pt,.3pt) 
			to[out=220,in=260,looseness=1.4] ++(-1.1pt,.5pt)
			to[out=190,in=230, in looseness=1.3] (235:3pt);
	\end{scope}
}

\newcommand{\tikzpeople@judge@colors}{
	shirt/200/{-1/-1},hair/160/{-.5/1.4},hairshadow/20/{.25/1.3}, skin/0/{.25/.4}, 
	undershirt/180/{-.6/-.6}%
}
