%% 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.
%%
%% This work consists of the files tikzpeople.tex, tikzpeople.sty,
%% tikzpeople.shape.alice.sty, tikzpeople.shape.bob.sty,
%% tikzpeople.shape.bride.sty, tikzpeople.shape.builder.sty,
%% tikzpeople.shape.businessman.sty, tikzpeople.shape.charlie.sty,
%% tikzpeople.shape.chef.sty, tikzpeople.shape.conductor.sty,
%% tikzpeople.shape.cowboy.sty, tikzpeople.shape.criminal.sty,
%% tikzpeople.shape.dave.sty, tikzpeople.shape.devil.sty,
%% tikzpeople.shape.duck.sty, tikzpeople.shape.graduate.sty,
%% tikzpeople.shape.groom.sty, tikzpeople.shape.guard.sty,
%% tikzpeople.shape.jester.sty, tikzpeople.shape.judge.sty,
%% tikzpeople.shape.maninblack.sty, tikzpeople.shape.mexican.sty,
%% tikzpeople.shape.nun.sty, tikzpeople.shape.nurse.sty,
%% tikzpeople.shape.physician.sty, tikzpeople.shape.pilot.sty,
%% tikzpeople.shape.police.sty, tikzpeople.shape.priest.sty,
%% tikzpeople.shape.sailor.sty, tikzpeople.shape.santa.sty,
%% tikzpeople.shape.surgeon.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tikzpeople}[2016/11/28 v0.3 People shaped nodes for Tikz]

\RequirePackage{tikz}
\RequirePackage{calc}
\RequirePackage{etoolbox}
\makeatletter
\newif\if@tikzpeople@draft\@tikzpeople@draftfalse
\DeclareOption{draft}{
  \@tikzpeople@drafttrue
}
\newif\if@tikzpeople@demo\@tikzpeople@demofalse
\DeclareOption{demo}{
  \@tikzpeople@demotrue
}
\newif\if@tikzpeople@nobeards\@tikzpeople@nobeardsfalse
\DeclareOption{nobeards}{
  \@tikzpeople@nobeardstrue
}
\newif\if@tikzpeople@saturated\@tikzpeople@saturatedfalse
\DeclareOption{saturated}{
  \@tikzpeople@saturatedtrue
}
\ProcessOptions\relax
\usepgflibrary{intersections}
\usetikzlibrary{decorations.markings,decorations.pathmorphing,calc,positioning,arrows.meta}

\newif\if@tikzpeople@mirrored
\pgfkeys{/tikz/mirrored/.is if=@tikzpeople@mirrored}
\newif\if@tikzpeople@female
\pgfkeys{/tikz/female/.is if=@tikzpeople@female}
\newif\if@tikzpeople@evil
\pgfkeys{/tikz/evil/.is if=@tikzpeople@evil}
\newif\if@tikzpeople@good
\pgfkeys{/tikz/good/.is if=@tikzpeople@good}
\newif\if@tikzpeople@monitor
\pgfkeys{/tikz/monitor/.is if=@tikzpeople@monitor}
\newif\if@tikzpeople@shield
\pgfkeys{/tikz/shield/.is if=@tikzpeople@shield}
\newif\if@tikzpeople@sword
\pgfkeys{/tikz/sword/.is if=@tikzpeople@sword}
\pgfkeys{/tikz/saturated/.is if=@tikzpeople@saturated}

\newcommand{\tikzpeople@addcolorkey}[1]{
	\expandafter\def\csname tikzpeople@#1\endcsname{#1}
	\pgfkeys{/tikz/#1/.code=\expandafter\def\csname tikzpeople@#1\endcsname{##1}}
}

\newcommand{\tikzpeople@addtextkey}[2]{
	\expandafter\def\csname tikzpeople@#1\endcsname{#2}
	\pgfkeys{/tikz/#1/.code=\expandafter\def\csname tikzpeople@#1\endcsname{##1}}
}

\tikzpeople@addcolorkey{horns}
\tikzpeople@addcolorkey{halo}
\tikzpeople@addcolorkey{shirt}
\tikzpeople@addcolorkey{undershirt}
\tikzpeople@addcolorkey{skin}
\tikzpeople@addcolorkey{hair}
\tikzpeople@addcolorkey{hat}
\tikzpeople@addcolorkey{pc}
\tikzpeople@addcolorkey{shieldmid}
\tikzpeople@addcolorkey{shieldedge}
\tikzpeople@addcolorkey{shieldrivets}
\tikzpeople@addcolorkey{swordblade}
\tikzpeople@addcolorkey{swordgrip}
\tikzpeople@addcolorkey{swordguard}
\tikzpeople@addcolorkey{swordpommel}

\pgfdeclareshape{person}{
	\saveddimen{\scalingfactor}{
		\setlength{\pgf@xa}{\pgfshapeminwidth}
		\setlength{\pgf@xb}{9.075pt}
		\ifdim\pgf@xa<\pgf@xb
			\pgfsetshapeminwidth{9.075pt}
		\fi
		\setlength{\pgf@xa}{\pgfshapeminheight}
		\setlength{\pgf@xb}{0.5cm}
		\ifdim\pgf@xa<\pgf@xb
			\pgfsetshapeminheight{0.5cm}
		\fi
		\setlength{\pgf@xa}{1pt*\ratio{\pgfshapeminwidth}{9.075pt}}
		\setlength{\pgf@xb}{1pt*\ratio{\pgfshapeminheight}{12.1pt}}
		\ifdim\pgf@xa<\pgf@xb
			\setlength{\pgf@x}{1pt*\ratio{\pgfshapeminheight}{12.1pt}}
		\else
			\setlength{\pgf@x}{1pt*\ratio{\pgfshapeminwidth}{9.075pt}}
		\fi
	}

	\saveddimen{\width}{
		\pgf@x=\wd\pgfnodeparttextbox
	}
	
	\saveddimen{\height}{
		\pgf@x=\ht\pgfnodeparttextbox
	}
	
	\saveddimen{\depth}{
		\pgf@x=\dp\pgfnodeparttextbox
	}
	
	\savedanchor{\mouth}{
		\if@tikzpeople@mirrored
			\pgfpoint{-2.075}{1.7}
		\else
			\pgfpoint{2.4}{1.7}
		\fi
	}
	
	\anchor{mouth}{
		\pgfpointscale{\scalingfactor}{\mouth}
	}
	\anchor{north west}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{6.3}}
	}
	\anchor{north}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{6.3}}
	}
	\anchor{north east}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{6.3}}
	}
	\anchor{east}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{0.25}}
	}
	\anchor{south east}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{-5.8}}
	}
	\anchor{south}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{-5.8}}
	}
	\anchor{south west}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{-5.8}}
	}
	\anchor{west}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{0.25}}
	}
	\anchor{center}{
		\pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{0.25}}
	}
	\anchor{text}{
		\pgfpoint{\scalingfactor*0.1625-0.5*\width}{\scalingfactor*-6.3-\depth-\height}
	}
	\anchor{base}{
		\pgfpoint{\scalingfactor*0.1625}{\scalingfactor*-6.3-\depth-\height}
	}
	\anchor{base west}{
		\pgfpoint{\scalingfactor*-4.375}{\scalingfactor*-6.3-\depth-\height}
	}
	\anchor{base east}{
		\pgfpoint{\scalingfactor*4.7}{\scalingfactor*-6.3-\depth-\height}
	}
	\anchor{mid}{
		\pgfpoint{\scalingfactor*0.1625}{\scalingfactor*-6.3-\depth-\height+.5ex}
	}
	\anchor{mid west}{
		\pgfpoint{\scalingfactor*-4.375}{\scalingfactor*-6.3-\depth-\height+.5ex}
	}
	\anchor{mid east}{
		\pgfpoint{\scalingfactor*4.7}{\scalingfactor*-6.3-\depth-\height+.5ex}
	}

	\anchorborder{
		\@tempdima=\pgf@x
		\@tempdimb=\pgf@y
		\pgftransformshift{\pgfpoint{\scalingfactor*-0.1625}{\scalingfactor*0.4pt}}
		\pgfpointborderellipse{\pgfpoint{\@tempdima}{\@tempdimb}}{\pgfpoint{\scalingfactor*5.9pt}{\scalingfactor*6.9pt}}
	}


	\beforebackgroundpath{	
		\pgftransformscale{\scalingfactor}
		\if@tikzpeople@mirrored
			\pgftransformxscale{-1}
			\pgftransformxshift{-0.325}
		\fi
		\pgftransformshift{\pgfpoint{-0.3}{3.3}}
		\if@tikzpeople@draft
			\tikzpeople@person@draftstyles
			\tikzpeople@person@paintshirt
			\tikzpeople@person@paintrighthorn
			\tikzpeople@person@painthead
			\tikzpeople@person@paintgoatee
			\tikzpeople@person@paintlefthorn
			\tikzpeople@person@painthalo
			\if@tikzpeople@shield
				\tikzpeople@person@paintshield
			\fi
			\if@tikzpeople@sword
				\tikzpeople@person@paintsword
			\fi
			\if@tikzpeople@monitor
				\tikzpeople@person@paintmonitor
			\fi
		\else
			\tikzpeople@definecommoncolors
			\tikzpeople@definecommonstyles
			\tikzpeople@person@paintshirt
			\tikzpeople@person@paintrighthorn
			\tikzpeople@person@painthead
			\tikzpeople@person@painthair
			\tikzpeople@person@paintlefthorn
			\tikzpeople@person@paintgoatee
			\tikzpeople@person@painthalo
			\if@tikzpeople@shield
				\tikzpeople@person@paintshield
			\fi
			\if@tikzpeople@sword
				\tikzpeople@person@paintsword
			\fi
			\if@tikzpeople@monitor
				\tikzpeople@person@paintmonitor
			\fi
		\fi
	}
}

\newcommand{\tikzpeople@definecommonstyles}{
	\if@tikzpeople@saturated
		\tikzset{
			shirt/.style=       {color=\tikzpeople@shirt,top color=\tikzpeople@shirt!70, bottom color=\tikzpeople@shirt,shading angle=45},
			hat/.style=         {color=\tikzpeople@hat,top color=\tikzpeople@hat!70, bottom color=\tikzpeople@hat,shading angle=45},
			undershirt/.style=  {color=\tikzpeople@undershirt,top color=\tikzpeople@undershirt!70, bottom color=\tikzpeople@undershirt,shading angle=45},
			skin/.style=        {color=\tikzpeople@skin,top color=\tikzpeople@skin!70, bottom color=\tikzpeople@skin,shading angle=45},
			hair/.style=        {color=\tikzpeople@hair,top color=\tikzpeople@hair!70, bottom color=\tikzpeople@hair,shading angle=45},
			goatee/.style=      {color=\tikzpeople@hair,top color=\tikzpeople@hair!70, bottom color=\tikzpeople@hair,shading angle=45},
			horns/.style=       {color=\tikzpeople@horns,top color=\tikzpeople@horns!70, bottom color=\tikzpeople@horns,shading angle=45},
			halo/.style=        {color=\tikzpeople@halo,top color=\tikzpeople@halo!70, bottom color=\tikzpeople@halo,shading angle=45},
			shieldmid/.style=   {color=\tikzpeople@shieldmid,top color=\tikzpeople@shieldmid!70, bottom color=\tikzpeople@shieldmid,shading angle=45,line join=bevel},
			shieldedge/.style=  {color=\tikzpeople@shieldedge,top color=\tikzpeople@shieldedge!70, bottom color=\tikzpeople@shieldedge,shading angle=45,line join=bevel},
			shieldrivets/.style={color=\tikzpeople@shieldrivets,top color=\tikzpeople@shieldrivets!70, bottom color=\tikzpeople@shieldrivets,shading angle=45},
			swordblade/.style=  {color=\tikzpeople@swordblade,top color=\tikzpeople@swordblade!70, bottom color=\tikzpeople@swordblade,shading angle=45},
			swordguard/.style=  {color=\tikzpeople@swordguard,top color=\tikzpeople@swordguard!70, bottom color=\tikzpeople@swordguard,shading angle=45},
			swordpommel/.style= {color=\tikzpeople@swordpommel,top color=\tikzpeople@swordpommel!70, bottom color=\tikzpeople@swordpommel,shading angle=45},
			swordgrip/.style=   {color=\tikzpeople@swordgrip,top color=\tikzpeople@swordgrip!70, bottom color=\tikzpeople@swordgrip,shading angle=45},
			monitor1/.style=    {color=\tikzpeople@pc, top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!70,shading angle=90},
			monitor2/.style=    {color=\tikzpeople@pc, top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!90,shading angle=90},
			monitor3/.style=    {color=\tikzpeople@pc, top color=\tikzpeople@pc!80, bottom color=\tikzpeople@pc!70,shading angle=90},
			monitor4/.style=    {color=\tikzpeople@pc, top color=\tikzpeople@pc!60, bottom color=\tikzpeople@pc!50,shading angle=90},
		}
	\else
		\tikzset{
			shirt/.style=       {color=\tikzpeople@shirt!80,top color=\tikzpeople@shirt!40, bottom color=\tikzpeople@shirt!80,shading angle=45},
			hat/.style=         {color=\tikzpeople@hat!80,top color=\tikzpeople@hat!40, bottom color=\tikzpeople@hat!80,shading angle=45},
			undershirt/.style=  {color=\tikzpeople@undershirt!80,top color=\tikzpeople@undershirt!40, bottom color=\tikzpeople@undershirt!80,shading angle=45},
			skin/.style=        {color=\tikzpeople@skin!80,top color=\tikzpeople@skin!40, bottom color=\tikzpeople@skin!80,shading angle=45},
			hair/.style=        {color=\tikzpeople@hair!80,top color=\tikzpeople@hair!40, bottom color=\tikzpeople@hair!80,shading angle=45},
			goatee/.style=      {color=\tikzpeople@hair!80,top color=\tikzpeople@hair!40, bottom color=\tikzpeople@hair!80,shading angle=45},
			horns/.style=       {color=\tikzpeople@horns!80,top color=\tikzpeople@horns!40, bottom color=\tikzpeople@horns!80,shading angle=45},
			halo/.style=        {color=\tikzpeople@halo!80,top color=\tikzpeople@halo!40, bottom color=\tikzpeople@halo!80,shading angle=45},
			shieldmid/.style=   {color=\tikzpeople@shieldmid!80,top color=\tikzpeople@shieldmid!40, bottom color=\tikzpeople@shieldmid!80,shading angle=45,line join=bevel},
			shieldedge/.style=  {color=\tikzpeople@shieldedge!80,top color=\tikzpeople@shieldedge!40, bottom color=\tikzpeople@shieldedge!80,shading angle=45,line join=bevel},
			shieldrivets/.style={color=\tikzpeople@shieldrivets!80,top color=\tikzpeople@shieldrivets!40, bottom color=\tikzpeople@shieldrivets!80,shading angle=45},
			swordblade/.style=  {color=\tikzpeople@swordblade!80,top color=\tikzpeople@swordblade!40, bottom color=\tikzpeople@swordblade!80,shading angle=45},
			swordguard/.style=  {color=\tikzpeople@swordguard!80,top color=\tikzpeople@swordguard!40, bottom color=\tikzpeople@swordguard!80,shading angle=45},
			swordpommel/.style= {color=\tikzpeople@swordpommel!80,top color=\tikzpeople@swordpommel!40, bottom color=\tikzpeople@swordpommel!80,shading angle=45},
			swordgrip/.style=   {color=\tikzpeople@swordgrip!80,top color=\tikzpeople@swordgrip!40, bottom color=\tikzpeople@swordgrip!80,shading angle=45},
			monitor1/.style=    {color=\tikzpeople@pc!80, top color=\tikzpeople@pc!80, bottom color=\tikzpeople@pc!40,shading angle=90},
			monitor2/.style=    {color=\tikzpeople@pc!80, top color=\tikzpeople@pc!80, bottom color=\tikzpeople@pc!70,shading angle=90},
			monitor3/.style=    {color=\tikzpeople@pc!80, top color=\tikzpeople@pc!60, bottom color=\tikzpeople@pc!50,shading angle=90},
			monitor4/.style=    {color=\tikzpeople@pc!80, top color=\tikzpeople@pc!40, bottom color=\tikzpeople@pc!30,shading angle=90},
		}
	\fi
}

\newcommand{\tikzpeople@person@draftstyles}{
	\tikzset{
			shirt/.style=       {color=black,fill=white},
			skin/.style=        {color=black,fill=white},
			goatee/.style=      {color=black,fill=white},
			horns/.style=       {color=black,fill=white},
			halo/.style=        {color=black,fill=white},
			shieldedge/.style=  {color=black,fill=white},
			swordblade/.style=  {color=black,fill=white},
			swordguard/.style=  {color=black,fill=white},
			swordpommel/.style= {color=black,fill=white},
			swordgrip/.style=   {color=black,fill=white},
		}
}

\newcommand{\tikzpeople@definecommoncolors}{
	\definecolor{horns}{named}{red}
	\definecolor{halo}{named}{yellow}
	\definecolor{skin}{rgb}{0.84,0.58,0.24}
	\definecolor{shirt}{rgb}{0.34,0.56,0.22}
	\definecolor{hair}{rgb}{0.45,0.24,0}
	\definecolor{pc}{rgb}{.2,.2,.2}
	\definecolor{shieldedge}{RGB}{83,84,85}
	\definecolor{shieldrivets}{RGB}{25,25,26}
	\definecolor{shieldmid}{RGB}{197,22,9}
	\definecolor{swordblade}{RGB}{83,84,85}
	\definecolor{swordguard}{RGB}{147,131,104}
	\definecolor{swordpommel}{RGB}{147,131,104}
	\definecolor{swordgrip}{RGB}{81,57,48}
}

\newcommand{\tikzpeople@person@paintshirt}{
	\draw[shirt] 
		(-4.0pt,-8.0pt) .. controls (-2pt,-10pt) and ( 3pt,-9pt) .. 
		( 5.0pt,-7.0pt) .. controls ( 5pt, 0pt) and (-5pt, 0pt) .. 
		(-4.0pt,-8.0pt) -- cycle;
}

\newcommand{\tikzpeople@person@painthead}{
	\draw[skin] (0pt,0pt) circle (3pt);
}

\newcommand{\tikzpeople@person@painthair}{
	\if@tikzpeople@female
		\tikzpeople@person@paintfemalehair
	\else
		\draw[hair]
			(25:3pt) arc (25:210:3pt) -- (-2.6pt,-0.5pt) -- (-1.7pt,-1pt) -- 
			(-1.7pt,0.8pt) to[out=350,in=210] (25:3pt) -- cycle;
	\fi
}

\newcommand{\tikzpeople@person@painthairstyletwo}{
	\if@tikzpeople@female
		\tikzpeople@person@paintfemalehairstyletwo
	\else
	\draw[hair]
		(15:3pt) arc (15:210:3pt) -- ++(0.3pt,0pt) -- ++(0.1pt,0.5pt)
		.. controls +(310:.2pt) .. ++(0.2pt,-0.6pt) -- ++(0.4pt,0pt) 
		.. controls +(90:1pt) .. (-1.7pt,0.4pt) to[out=350,in=210]
		(15:3pt) -- cycle;
	\fi
}

\newcommand{\tikzpeople@person@paintfemalehairstyletwo}{
	\draw[hair]
		(15:3pt) arc (15:165:3pt) .. controls +(260:1pt) .. (215:4.5pt) -- 
		++(4:0.5pt) -- ++(70:0.5pt) -- ++(285:0.4pt) -- ++(0:1.5pt) --
		(-1.6pt,0pt) to [out=350,in=210] (15:3pt) -- cycle;
}

\newcommand{\tikzpeople@person@paintfemalehairstylethree}{
	\draw[hair]
		(15:3pt) arc (15:180:3.3pt) .. controls +(269:3pt) and +(190:1.5pt) 
		.. (250:3.4pt) .. controls +(118:1.2pt) .. (-1.6pt,0pt) to [out=350,in=210]
		(15:3pt)-- cycle;
}

\newcommand{\tikzpeople@person@paintgoatee}{
\if@tikzpeople@nobeards
\else
	\if@tikzpeople@evil
		{
			\pgftransformrotate{5}
			\draw[goatee] (285:1.75pt) 
			-- ++(0:1pt) arc[start angle=90, end angle=0, x radius=.55pt, y radius=.5pt]
			-- ++(270:.5pt) arc[start angle=0, end angle=-90, x radius=.55pt, y radius=.5pt]
			-- ++(180:1pt) arc[start angle=-90, end angle=-180, x radius=.55pt, y radius=.5pt]
			-- ++(90:.5pt) arc[start angle=180, end angle=90, x radius=.55pt, y radius=.5pt]
			(285:1.75pt) ++(.1875pt,-.3pt) 
			arc[start angle=90,end angle=270,x radius=.45pt, y radius=.3pt]
			-- ++(0:.6pt) arc[start angle=-90,end angle=90,x radius=.45pt, y radius=.3pt] 
			-- ++(180:.6pt);
		}
	\fi
\fi
}

\newcommand{\tikzpeople@person@paintlefthorn}{
	\if@tikzpeople@evil
		\draw[horns] 
			(140:2.5pt) arc (-90:-170:2pt) arc (0:180:0.04pt) arc (190:240:4pt) 
			to[out=70,in=290] (140:2.5pt) -- cycle;
	\fi
}

\newcommand{\tikzpeople@person@paintrighthorn}{
	\if@tikzpeople@evil
		\draw[horns] 
			(40:2.5pt) arc (-90:-10:2pt) arc (180:0:0.04pt) arc (-10:-60:4pt) 
			to[out=110,in=250] (40:2.5pt) -- cycle;
	\fi
}

\newcommand{\tikzpeople@person@painthalo}{
	\if@tikzpeople@good
		\draw[fill,halo,even odd rule]
			(0.1pt,4.5pt) ellipse (2.8pt and 0.8pt)	++(0pt,.1pt) ellipse 
			(2pt and 0.5pt);
	\fi
}

\newcommand{\tikzpeople@person@paintfemalehair}{
	\draw[hair]
		(15:3pt) arc (15:180:3pt) .. controls +(273:2pt) and +(190:2pt) .. 
		(260:3.3pt) .. controls +(140:1pt) .. (-1.6pt,0pt) to [out=350,in=210]
		(15:3pt) -- cycle;
}

\newcommand{\tikzpeople@person@paintshield}{
	\path
		(1pt,-3.7pt) coordinate (tikzpeople@shield1) +(-.2pt,.1pt) coordinate 
		(tikzpeople@shield6) ++(1.2pt,1.2pt) coordinate (tikzpeople@shield2) 
		++(3.5pt,1.3pt) coordinate (tikzpeople@shield3) ++(.8pt,-.75pt) coordinate 
		(tikzpeople@shield4) ++(-2pt,-6.5pt) coordinate (tikzpeople@shield5) 
		--cycle;
	\draw[shieldedge] 
		(tikzpeople@shield1) -- (tikzpeople@shield6) to[out=0,in=270] 
		++(1.2pt,1.2pt) -- (tikzpeople@shield2) to[out=270,in=0] 
		(tikzpeople@shield1) --cycle;
	\draw[shieldedge]
		(tikzpeople@shield3) -- ++(-.2pt,.1pt) to[out=265,in=220] 
		++(.8pt,-.75pt) -- (tikzpeople@shield4) to[out=220,in=265] 
		(tikzpeople@shield3) --cycle;
	\draw[shieldedge] 
		(tikzpeople@shield2) -- ++(-.2pt,.1pt) .. controls +(5:1.5pt) and 
		+(220:1.5pt) .. ++(3.5pt,1.3pt) -- (tikzpeople@shield3) .. controls 
		+(220:1.5pt) and +(5:1.5pt) .. (tikzpeople@shield2) --cycle;
	\draw[shieldedge] 
		(tikzpeople@shield5) -- ++(-.2pt,.1pt) .. controls +(170:1.5pt) and 
		+(270:3pt) .. (tikzpeople@shield6) -- (tikzpeople@shield1) .. controls 
		+(270:3pt) and +(170:1.5pt) .. (tikzpeople@shield5) --cycle;
	\draw[shieldedge] 
		(tikzpeople@shield1) to[out=0,in=270] (tikzpeople@shield2) .. controls 
		+(5:1.5pt) and +(220:1.5pt)	.. (tikzpeople@shield3) to[out=265,in=220] 
		(tikzpeople@shield4) .. controls +(270:3pt) and +(30:1.5pt) .. 
		(tikzpeople@shield5) .. controls +(170:1.5pt) and +(270:3pt) .. 
		(tikzpeople@shield1) --cycle;
	\if@tikzpeople@draft\else
		\draw[shieldmid] 
			($(tikzpeople@shield1)+(315:.5pt)$) to[out=10,in=260] 
			($(tikzpeople@shield2)+(315:.5pt)$) .. controls +(7:1.2pt) and 
			+(215:1.2pt) .. ($(tikzpeople@shield3)+(250:.75pt)$) to[out=280,in=180] 
			($(tikzpeople@shield4)+(235:.625pt)$) .. controls +(270:2.2pt) and 
			+(30:1.1pt) .. ($(tikzpeople@shield5)+(90:.5pt)$) .. controls 
			+(172:1.1pt) and +(271:2.2pt) .. ($(tikzpeople@shield1)+(315:.5pt)$) 
			--cycle;
		\begin{scope}
			\clip 
				($(tikzpeople@shield1)+(315:.3pt)$) coordinate (tikzpeople@rivet1) circle (.05pt)
				($(tikzpeople@shield2)+(315:.3pt)$) coordinate (tikzpeople@rivet2) circle (.05pt)
				($(tikzpeople@shield3)+(250:.45pt)$) coordinate (tikzpeople@rivet3) circle (.05pt)
				($(tikzpeople@shield4)+(235:.4pt)$) coordinate (tikzpeople@rivet4) circle (.05pt)
				($(tikzpeople@shield5)+(90:.3pt)$) coordinate (tikzpeople@rivet5) circle (.05pt);
				\path[shieldrivets] (tikzpeople@rivet1) ++(-.025pt,.025pt) circle (.12pt);
				\path[shieldrivets] (tikzpeople@rivet2) ++(-.025pt,.025pt) circle (.12pt);
				\path[shieldrivets] (tikzpeople@rivet3) ++(-.025pt,.025pt) circle (.12pt);
				\path[shieldrivets] (tikzpeople@rivet4) ++(-.025pt,.025pt) circle (.12pt);
				\path[shieldrivets] (tikzpeople@rivet5) ++(-.025pt,.025pt) circle (.12pt);
		\end{scope}
	\fi
}

\newcommand{\tikzpeople@person@paintsword}{
	\begin{scope}
		\pgftransformrotate{-30}
		\pgftransformshift{\pgfpoint{1.7pt}{-.2pt}}
		\draw[swordpommel]
			(-.4pt,-8.9pt) -- ++(0pt,-.1pt) arc (180:360:.4pt and .15pt) -- 
			++(0pt,.1pt); ellipse (.4pt and .15pt);
		\draw[swordpommel] (0pt,-8.9pt) ellipse (.4pt and .15pt);
		\draw[swordgrip] 
			(-.2pt,-7.1pt) to[out=265,in=95] (-.2pt,-8.9pt) to[out=345,in=195] 
			(.2pt,-8.9pt) to[out=85,in=275] (.2pt,-7.1pt);
		\draw[skin] (0pt,-8.1pt) ellipse (.6pt and .7pt);
		\draw[swordguard] 
			(0pt,-7.45pt) to[out=0,in=270] (1.4pt,-6.5pt) -- ++(-.1pt,-.1pt) 
			to[out=270,in=0] (0pt,-7.45pt); to[out=0,in=270] (1.2pt,-6.6pt) -- 
			++(.1pt,.1pt) to[out=270,in=0] (0pt,-6.8pt);
		\draw[swordguard] 
			(0pt,-6.8pt) to[out=180,in=270] (-1.1pt,-6.5pt) -- ++(-.1pt,-.1pt) 
			to[out=270,in=180] (0pt,-7.2pt) to[out=0,in=270] (1.2pt,-6.6pt) -- 
			++(.1pt,.1pt) to[out=270,in=0] (0pt,-6.8pt);
		\draw[swordguard] 
			(-1.2pt,-6.6pt) -- ++(0.1pt,0.1pt) -- ++(-0.1pt,0pt) -- ++(-0.1pt,-0.1pt) 
			--cycle;
		\draw[swordguard] 
			(1.2pt,-6.6pt) -- ++(0.1pt,0.1pt) -- ++(0.1pt,0pt) -- ++(-0.1pt,-0.1pt) 
			--cycle;
		\draw[swordguard] 
			(0pt,-7.2pt) to[out=180,in=270] (-1.2pt,-6.6pt) -- ++(-.1pt,0pt) 
			to[out=270,in=180] (0pt,-7.45pt) to[out=0,in=270] (1.3pt,-6.6pt) -- 
			++(-.1pt,0pt) to[out=270,in=0] (0pt,-7.2pt);
		\draw[swordblade] 
			(-.4pt,-7pt) -- (-.4pt,-1.5pt) to[out=90,in=240] (0pt,2pt) 
			to[out=300,in=90] (.4pt,-1.5pt) -- (.4pt,-7pt) to[out=190,in=350] 
			(-.4pt,-7pt);
		{
			\clip 
				(-.4pt,-7pt) -- (-.4pt,-1.5pt) to[out=90,in=240] (0pt,1pt) 
				to[out=300,in=90] (.4pt,-1.5pt) -- (.4pt,-7pt) to[out=190,in=350] 
				(-.4pt,-7pt);
			\draw[swordblade, line width=.05*\scalingfactor,cap=round] 
				(0pt,-7.04pt) -- (0pt,.7pt);
		}
	\end{scope}
}

\newcommand{\tikzpeople@person@paintmonitor}{
	\if@tikzpeople@draft
		\path[draw=black,fill=white] 
			(2.3pt,-2.3pt) -- ++(14:7.3pt) -- ++(340:.27pt) coordinate (tikzpeople@tmp) -- 
			++(264:6.2pt) -- ++(195.5:7.35pt) coordinate (tikzpeople@tmp2) -- ++(135:.3pt) 
			--cycle;
		\path[draw=black] 
			(2.3pt,-2.3pt) ++(330:.28pt) coordinate (tikzpeople@tmp3) 
			(tikzpeople@tmp2) -- (tikzpeople@tmp3) -- (tikzpeople@tmp);
		\path[draw=black] 
			(3pt,-3pt) -- ++(14.5:6.4pt) -- ++(264:5.3pt) -- ++(195.5:6.35pt) 
			coordinate (tikzpeople@tmp) --cycle;
		\path[draw=black,line width=.15*\scalingfactor,cap=butt] 
			(tikzpeople@tmp) -- (3pt,-3pt) -- ++(14.5:6.4pt);
		\path[draw=black,fill=white] 
			(6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) coordinate (tikzpeople@tmp) 
			-- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(145:1.6pt) --cycle;
		\path[draw=black] 
			(tikzpeople@tmp) -- ++(0,-.2pt) -- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(0,.2pt);
		\path (6.1pt,-4.8pt) ++(17:.8pt) coordinate (tikzpeople@tmp);
		\path[draw=black,fill=white] 
			(tikzpeople@tmp) ++(0,.01pt) -- ++(194:1.5pt) -- ++(280:4pt) -- ++(0:.07pt) -- 
			++(17:.5pt) --cycle;
		\path[draw=black,fill=white] 
			(6.1pt,-4.8pt) ++(190:.6pt) -- ++(280:4pt) coordinate (tikzpeople@tmp2) -- ++(15:2pt)
			-- (tikzpeople@tmp) --cycle;
	\else
		\path[monitor1]
			(2.3pt,-2.3pt) -- ++(14:7.3pt) -- ++(340:.27pt) coordinate (tikzpeople@tmp) -- 
			++(195:7.3pt) -- ++(264:6.2pt) coordinate (tikzpeople@tmp2) -- ++(150:.27pt) --cycle;
		\path[monitor3]
			(2.3pt,-2.3pt) ++(330:.28pt) -- (tikzpeople@tmp) -- ++(264:6.2pt) -- (tikzpeople@tmp2) --cycle;
		\path[monitor4] 
			(3pt,-3pt) -- ++(14.5:6.4pt) -- ++(264:5pt) -- ++(195:6.35pt) 
			coordinate (tikzpeople@tmp) --cycle;
		\path[draw,color=\tikzpeople@pc\if@tikzpeople@saturated\else!80\fi,line width=.15*\scalingfactor,cap=butt] 
			(tikzpeople@tmp) -- (3pt,-3pt) -- ++(14.5:6.4pt);
		\begin{scope}
			\pgftransformshift{\pgfpoint{6pt}{-4.7pt}}
			\pgftransformxslant{0.15}
			\path[monitor1] 
				(0,0) ellipse (1.3pt and 2pt);
			\path[monitor3] 
				(.1pt,-.1pt) ellipse (1.3pt and 2pt);
		\end{scope}
		\path[monitor2] 
			(6.05pt,-4.8pt) ++(160:.9pt) -- ++(15:2pt) -- ++(265:1pt) -- ++(195:2pt) 
			--cycle;
		\path (6.1pt,-4.8pt) ++(17:.8pt) coordinate (tikzpeople@tmp);
		\path[monitor1] 
			(6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) -- ++(0,-.2pt) -- 
			++(325:1.6pt) -- ++(15:3.7pt) -- ++(0,.2pt) -- cycle;
		\path[monitor3] 
			(6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) -- ++(325:1.6pt) 
			-- ++(15:3.7pt) -- ++(145:1.6pt) --cycle;
		\path[monitor2] 
			(6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-.6pt,.2pt) -- ++(325:.8pt) -- 
			++(15:2.5pt) -- ++(145:.8pt) --cycle;
		\path[monitor2] 
			(tikzpeople@tmp) ++(0,.01pt) -- ++(194:1.5pt) -- ++(280:4pt) -- ++(0:.07pt) -- 
			++(17:.5pt) --cycle;
		\path[monitor3] 
			(6.1pt,-4.8pt) ++(190:.6pt) -- ++(280:4pt) coordinate (tikzpeople@tmp2) -- ++(15:2pt)
			-- (tikzpeople@tmp) --cycle;
	\fi
}


\newcommand{\tikzpeople@declareshape}[1]{
	\if@tikzpeople@draft
		\pgfdeclareshape{#1}{
		\inheritsavedanchors[from={person}]
		\inheritanchor[from={person}]{north west}
		\inheritanchor[from={person}]{north}
		\inheritanchor[from={person}]{north east}
		\inheritanchor[from={person}]{east}
		\inheritanchor[from={person}]{south east}
		\inheritanchor[from={person}]{south}
		\inheritanchor[from={person}]{south west}
		\inheritanchor[from={person}]{west}
		\inheritanchor[from={person}]{center}
		\inheritanchor[from={person}]{text}
		\inheritanchor[from={person}]{base}
		\inheritanchor[from={person}]{base west}
		\inheritanchor[from={person}]{base east}
		\inheritanchor[from={person}]{mid}
		\inheritanchor[from={person}]{mid west}
		\inheritanchor[from={person}]{mid east}
		\inheritanchor[from={person}]{mouth}
		\inheritanchorborder[from={person}]
	
		\beforebackgroundpath{
			\pgftransformscale{\scalingfactor}
			\if@tikzpeople@mirrored
				\pgftransformxscale{-1}
				\pgftransformxshift{-0.325}
			\fi
			\pgftransformshift{\pgfpoint{-0.3}{3.3}}
			\tikzpeople@person@draftstyles
			\tikzpeople@person@paintshirt
			\tikzpeople@person@paintrighthorn
			\tikzpeople@person@painthead
			\tikzpeople@person@paintgoatee
			\tikzpeople@person@paintlefthorn
			\tikzpeople@person@painthalo
			\if@tikzpeople@shield
				\tikzpeople@person@paintshield
			\fi
			\if@tikzpeople@sword
				\tikzpeople@person@paintsword
			\fi
			\if@tikzpeople@monitor
				\tikzpeople@person@paintmonitor
			\fi
		}
	}
	\else
	\input{tikzpeople.shape.#1.sty}
	\pgfdeclareshape{#1}{
		\inheritsavedanchors[from={person}]
		\inheritanchor[from={person}]{north west}
		\inheritanchor[from={person}]{north}
		\inheritanchor[from={person}]{north east}
		\inheritanchor[from={person}]{east}
		\inheritanchor[from={person}]{south east}
		\inheritanchor[from={person}]{south}
		\inheritanchor[from={person}]{south west}
		\inheritanchor[from={person}]{west}
		\inheritanchor[from={person}]{center}
		\inheritanchor[from={person}]{text}
		\inheritanchor[from={person}]{base}
		\inheritanchor[from={person}]{base west}
		\inheritanchor[from={person}]{base east}
		\inheritanchor[from={person}]{mid}
		\inheritanchor[from={person}]{mid west}
		\inheritanchor[from={person}]{mid east}
		\inheritanchor[from={person}]{mouth}
		\inheritanchorborder[from={person}]
	
		\beforebackgroundpath{
			\pgftransformscale{\scalingfactor}
			\if@tikzpeople@mirrored
				\pgftransformxscale{-1}
				\pgftransformxshift{-0.325}
			\fi
			\pgftransformshift{\pgfpoint{-0.3}{3.3}}
			\tikzpeople@definecommoncolors
			\csname tikzpeople@#1@definecolors\endcsname
			\tikzpeople@definecommonstyles
			\csname tikzpeople@#1@definestyles\endcsname
			\begin{scope}
				\csname tikzpeople@#1@paint\endcsname
			\end{scope}
			\if@tikzpeople@shield
				\tikzpeople@person@paintshield
			\fi
			\if@tikzpeople@sword
				\tikzpeople@person@paintsword
			\fi
			\if@tikzpeople@monitor
				\tikzpeople@person@paintmonitor
			\fi
		}
	}
	\fi
	\if@tikzpeople@demo
		\ifdef{\tikzpeople@shapelist}{
			\appto\tikzpeople@shapelist{,#1}
		}{
			\def\tikzpeople@shapelist{#1}
		}
		\stepcounter{tikzpeople@totalshapes}
	\fi
}

\if@tikzpeople@demo
	\RequirePackage{xparse}
	\RequirePackage{capt-of}
	\RequirePackage{xifthen}
	\newcounter{tikzpeople@shaperow}
	\newcounter{tikzpeople@shapecolumn}
	\newcounter{tikzpeople@shapenum}
	\newcounter{tikzpeople@totalshapes}
	\newlength{\tikzpeople@figwidth}
	\newlength{\tikzpeople@captionht}

	\newcommand{\tikzpeople@horizontalseparation}[1]{
		\draw
			($#1*(-1,1.25) + {2.5*#1}*(0,-\value{tikzpeople@shaperow})$) -- 
			+(${2*#1}*(\value{tikzpeople@shapecolumn},0)$);			
	}

	\newcommand{\tikzpeople@verticalseparation}[1]{
		\draw 
			($#1*(-1,1.25) + {2*#1}*(\value{tikzpeople@shapecolumn},0) + {2.5*#1}*(0,-\value{tikzpeople@shaperow})$)
			-- +($2.5*(0,-#1)$);
	}

	\NewDocumentCommand\alltikzpeople{smm}{%
		\setlength{\tikzpeople@figwidth}{#2cm}
		\edef\tikzpeople@foreachshape{\noexpand\foreach \noexpand\tikzpeople@shape in {\tikzpeople@shapelist}}
		\edef\tikzpeople@numcols{\the\numexpr(\textwidth-(\tikzpeople@figwidth))/(2*\tikzpeople@figwidth)\relax}
		\addtocounter{figure}{10}
		\settototalheight{\tikzpeople@captionht}{%
			\vbox{\captionof{figure}{All available characters with \texttt{minimum width=#2cm} and no additional options.}}
		}%
		\addtocounter{figure}{-11}
		\edef\tikzpeople@numrows{\the\numexpr(2*(\textheight-\tikzpeople@captionht)-(5*\tikzpeople@figwidth/2))/(5*\tikzpeople@figwidth)\relax}
		\edef\tikzpeople@numshapes{\the\numexpr\tikzpeople@numcols*\tikzpeople@numrows\relax}
		\edef\tikzpeople@numfigs{\the\numexpr\value{tikzpeople@totalshapes}/\tikzpeople@numshapes\relax}
		\ifthenelse{\numexpr\tikzpeople@numfigs*\tikzpeople@numshapes\relax<\value{tikzpeople@totalshapes}}{
			\edef\tikzpeople@numfigs{\the\numexpr\tikzpeople@numfigs+1\relax}
		}{}
		\foreach \tikzpeople@fignum in {1,...,\tikzpeople@numfigs}{
			\begin{figure}[Htp]
				\centering
					\setcounter{tikzpeople@shapecolumn}{0}
					\setcounter{tikzpeople@shaperow}{0}
					\setcounter{tikzpeople@shapenum}{0}
				\begin{tikzpicture}
					\tikzpeople@foreachshape{
						\stepcounter{tikzpeople@shapenum}
						\ifthenelse{\value{tikzpeople@shapenum} > \numexpr(\tikzpeople@fignum-1)*\tikzpeople@numshapes\relax}{
							\ifthenelse{\value{tikzpeople@shapenum} < \numexpr\tikzpeople@fignum*\tikzpeople@numshapes+1\relax}{
								\coordinate (\tikzpeople@shape) at (${2*#2}*(\value{tikzpeople@shapecolumn},0) + {2.5*#2}*(0,-\value{tikzpeople@shaperow})$);
								\node[minimum width=#2cm,\tikzpeople@shape,#3] at (\tikzpeople@shape) {\texttt{\IfBooleanTF#1{}{\tikzpeople@shape}}};
								\tikzpeople@verticalseparation{#2}
								\stepcounter{tikzpeople@shapecolumn}
								\ifthenelse{\value{tikzpeople@shapecolumn}=\tikzpeople@numcols}{
									\tikzpeople@verticalseparation{#2}
									\ifthenelse{\value{tikzpeople@shaperow}=0}{\tikzpeople@horizontalseparation{#2}}{}
									\stepcounter{tikzpeople@shaperow}
									\tikzpeople@horizontalseparation{#2}
									\setcounter{tikzpeople@shapecolumn}{0}
								}{}
							}{}
						}{}
					}
					\ifthenelse{\value{tikzpeople@shapecolumn}=0}{}{
						\tikzpeople@verticalseparation{#2}
						\ifthenelse{\value{tikzpeople@shaperow}=0}{\tikzpeople@horizontalseparation{#2}}{}
						\stepcounter{tikzpeople@shaperow}
						\tikzpeople@horizontalseparation{#2}
					}
				\end{tikzpicture}
				\caption{\tikzpeople@captiontext{#2}{#3}}
				\label{fig:tikzpeoplefigure\tikzpeople@fignum}
			\end{figure}
		}
	}

	\newcommand{\tikzpeople@captiontext}[2]{
		\ifstrempty{#2}{
			All available characters with \texttt{minimum width=#1cm} and no additional options. %
		}{%
			All available characters with \texttt{minimum width=#1cm} and \texttt{#2} options. %
		}%
		\ifnum\tikzpeople@numfigs>1%
			(Part \tikzpeople@fignum~of \tikzpeople@numfigs)
		\fi
	}

	\newcommand{\tikzpeoplecolors}[1]{
		\begin{minipage}{.95\textwidth}
			\begin{center}
				\centering
				\expandafter\let\expandafter\tikzpeople@peoplecolors\csname tikzpeople@#1@colors\endcsname
				\begin{tikzpicture}
					\node[minimum width=2.5cm,#1] {};
					\foreach \tikzpeople@name/\tikzpeople@angle/\tikzpeople@coords in \tikzpeople@peoplecolors{
						\node (label) at (\tikzpeople@angle:2.5) {\tikzpeople@name};
						\foreach \x/\y in \tikzpeople@coords{
							\draw (label) edge (\x,\y);
						}
					}
				\end{tikzpicture}
				\captionof{figure}{The available color-keys for \texttt{#1} tikzpeople.}
			\end{center}
		\end{minipage}
	}

\fi

\tikzpeople@declareshape{alice}
\tikzpeople@declareshape{bob}
\tikzpeople@declareshape{bride}
\tikzpeople@declareshape{builder}
\tikzpeople@declareshape{businessman}
\tikzpeople@declareshape{charlie}
\tikzpeople@declareshape{chef}
\tikzpeople@declareshape{conductor}
\tikzpeople@declareshape{cowboy}
\tikzpeople@declareshape{criminal}
\tikzpeople@declareshape{dave}
\tikzpeople@declareshape{devil}
\tikzpeople@declareshape{duck}
\tikzpeople@declareshape{graduate}
\tikzpeople@declareshape{groom}
\tikzpeople@declareshape{guard}
\tikzpeople@declareshape{jester}
\tikzpeople@declareshape{judge}
\tikzpeople@declareshape{maninblack}
\tikzpeople@declareshape{mexican}
\tikzpeople@declareshape{nun}
\tikzpeople@declareshape{nurse}
\tikzpeople@declareshape{physician}
\tikzpeople@declareshape{pilot}
\tikzpeople@declareshape{police}
\tikzpeople@declareshape{priest}
\tikzpeople@declareshape{sailor}
\tikzpeople@declareshape{santa}
\tikzpeople@declareshape{surgeon}

\let\pgfmath@function@veclen\relax
\pgfmathdeclarefunction{veclen}{2}{%
  \begingroup%
  \pgfmath@x#1pt\relax%
  \pgfmath@y#2pt\relax%
  \ifdim\pgfmath@x<0pt\relax%
  \pgfmath@x-\pgfmath@x%
  \fi%
  \ifdim\pgfmath@y<0pt\relax%
  \pgfmath@y-\pgfmath@y%
  \fi%
  \ifdim\pgfmath@x=0pt\relax%
  \pgfmath@x\pgfmath@y%
  \else%
  \ifdim\pgfmath@y=0pt\relax%
  \else%
  \ifdim\pgfmath@x>\pgfmath@y%
  \pgfmath@xa\pgfmath@x%
  \pgfmath@x\pgfmath@y%
  \pgfmath@y\pgfmath@xa%
  \fi%
  % We use a scaling factor to reduce errors.
  % First, see if we should scale down
  \let\pgfmath@tmp@scale=\divide
  \let\pgfmath@tmp@restore=\multipy
  \ifdim\pgfmath@y>10000pt\relax%
  \c@pgfmath@counta1500\relax%
  \else%
  \ifdim\pgfmath@y>1000pt\relax%
  \c@pgfmath@counta150\relax%
  \else%
  \ifdim\pgfmath@y>100pt\relax%
  \c@pgfmath@counta50\relax%
  \else%
  % Not scaling down, should we scale up?
  \let\pgfmath@tmp@scale=\multiply
  \let\pgfmath@tmp@restore=\divide
  \ifdim\pgfmath@y<0.00001pt\relax%
  \c@pgfmath@counta1500\relax%
  \else%
  \ifdim\pgfmath@y<0.0001pt\relax%
  \c@pgfmath@counta150\relax%
  \else%
  \ifdim\pgfmath@y<0.001pt\relax%
  \c@pgfmath@counta50\relax%
  \else
  \c@pgfmath@counta1\relax%
  \fi%
  \fi%
  \fi%
  \fi%
  \fi%
  \fi%
  \pgfmath@tmp@scale\pgfmath@x\c@pgfmath@counta\relax%
  \pgfmath@tmp@scale\pgfmath@y\c@pgfmath@counta\relax%
  \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}%
  \pgfmath@x\pgfmathresult\pgfmath@x%
  \pgfmath@xa\pgfmath@tonumber{\pgfmath@x}\pgfmath@x%
  \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@xa}}%
  %
  % Use A+x^2*(B+x^2*(C+x^2*(D+E*x^2))) 
  % where
  % A = +1.000012594
  % B = +0.4993615349 
  % C = -0.1195159052
  % D = +0.04453994279
  % E = -0.01019210944
  %
  \pgfmath@x-0.01019210944\pgfmath@xa%
  \advance\pgfmath@x0.04453994279pt\relax%
  \pgfmath@x\pgfmath@temp\pgfmath@x%
  \advance\pgfmath@x-0.1195159052pt\relax%
  \pgfmath@x\pgfmath@temp\pgfmath@x%
  \advance\pgfmath@x0.4993615349pt\relax%
  \pgfmath@x\pgfmath@temp\pgfmath@x%
  \advance\pgfmath@x1.000012594pt\relax%
  \ifdim\pgfmath@y<0pt\relax%
  \pgfmath@y-\pgfmath@y%
  \fi%
  \pgfmath@x\pgfmath@tonumber{\pgfmath@y}\pgfmath@x%
  % Invert the scaling factor.
  \pgfmath@tmp@restore\pgfmath@x\c@pgfmath@counta\relax%
  \fi%
  \fi%
  \pgfmath@returnone\pgfmath@x%
  \endgroup%
}

\makeatother
