% Florian Sihler, 2022
% Licensed under GNU General Public License version 3
% https://opensource.org/licenses/gpl-3.0.html
\pingu@create@extra{strawhat}{%
  % extra strawhat (tikzducks basis)
  straw hat/.forward to         = /pingu/strawhat,
  strawhat/.default             = brown!50!white,
  strawhat/.code                = \pingu@set@extra{strawhat}{true}\pingu@color{strawhat}{#1},
  straw hat ribbon/.forward to  = /pingu/strawhat ribbon,
  strawhat ribbon/.code         = \pingu@color{strawhat@ribbon}{#1},
  straw hat position/.forward to= /pingu/strawhat position,
  strawhat position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@strawhat@angle{#1}\def\pingu@x@strawhat@xshift{#2}\def\pingu@x@strawhat@yshift{#3}\def\pingu@x@strawhat@scale{#4}},
}{strawhat ribbon= gray!85!black,strawhat position={-26.5:(-.185cm,.14cm){1.375}}}

\def\pingu@draw@ea@strawhat{%
\scope[rotate around={\pingu@x@strawhat@angle:(\pingu@name-head)},shift={(\pingu@name-head)},shift={(\pingu@x@strawhat@xshift,\pingu@x@strawhat@yshift)},scale=\pingu@x@strawhat@scale]
\pingu@block{\pingu@color@strawhat} (.34cm,0) ellipse[x radius=.75cm, y radius=\pingu@one];
\pingu@block{\pingu@color@strawhat} (0,.5mm) rectangle (.68cm,5mm);
\pingu@block{\pingu@color@strawhat} (.34cm,5mm) ellipse[x radius=.34cm, y radius=.8mm];
\pingu@block{\pingu@color@strawhat} (-.3955cm,.2mm) -- (1.0755cm,.2mm) -- (.68cm,2mm) -- (0,2mm) -- cycle;
\pingu@block{\pingu@color@strawhat@ribbon} (.34cm,2mm) ellipse[x radius=.34cm, y radius=.8mm];
\pingu@block{\pingu@color@strawhat@ribbon} (0,2mm) rectangle (.68cm,3mm);
\pingu@block{\pingu@color@strawhat} (.34cm,3mm) ellipse[x radius=.34cm, y radius=.8mm];
\endscope}

\pingu@create@extra{hat}{%
  hat/.default   = pingu@black!90!black,
  hat/.code      = \pingu@set@extra{hat}{true}\pingu@color{hat}{#1},
  hat base/.code = \pingu@color{hat@base}{#1},
  hat coronal/.code = \pingu@color{hat@coronal}{#1},
  hat ribbon/.code = \pingu@color{hat@ribbon}{#1},
  hat position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@hat@angle{#1}\def\pingu@x@hat@xshift{#2}\def\pingu@x@hat@yshift{#3}\def\pingu@x@hat@scale{#4}},
}{hat position={-2:(.35mm,0)1},hat base=\pingu@color@hat,hat coronal=\pingu@color@hat!91!white,hat ribbon=\pingu@color@hat!87!white}

\newdimen\pingu@hat@w@half \pingu@hat@w@half=.925cm
\newdimen\pingu@hat@h \pingu@hat@h=.625cm
\def\pingupathhatupper{[rounded corners=.25mm](-.65cm,-.25cm) to[out=90,in=200] ++(.35cm,\pingu@hat@h) to[bend left=11] ++(.25cm,0) to[bend right=2.5] ++(\pingu@one,0) to[bend left=11] ++(.25cm,0) to[out=-20,in=90] ++(.35cm,-\pingu@hat@h) to[bend left=12] (-.65cm,-.25cm) -- cycle}
\def\pingu@draw@ea@hat{%
\scope[rotate around={\pingu@x@hat@angle:(\pingu@name-head-top)},shift={(\pingu@name-head-top)},shift={(\pingu@x@hat@xshift,\pingu@x@hat@yshift)},scale=\pingu@x@hat@scale]
\pingu@block[/pingu/@draw=\pingu@color@hat@coronal,thick]{\pingu@color@hat@base} (0,-.25cm)++(180:\pingu@hat@w@half{} and .15cm) arc (180:360:\pingu@hat@w@half{} and .15cm) arc (0:180:\pingu@hat@w@half{} and .115cm) -- cycle;
\pingu@block{\pingu@color@hat} \pingupathhatupper;
\scope
\clip\pingupathhatupper;
\pingu@block{\pingu@color@hat@ribbon} (\z@,.2mm) ellipse [x radius=.95\pingu@hat@w@half, y radius=.13cm];
\pingu@block{\pingu@color@hat} (\z@,.134cm) ellipse [x radius=.95\pingu@hat@w@half, y radius=.13cm];
\endscope\endscope}

\pingu@create@extra{cap}{%
  cap/.default      = pingu@bronze,
  cap/.code         = \pingu@set@extra{cap}{true}\pingu@color{cap}{#1},
  cap padding/.code = {\def\pingu@x@cap@padding{#1}},
  cap extra height/.code = {\def\pingu@x@cap@height{#1}},
}{cap padding=.8mm, cap extra height=0pt}

\def\pingu@draw@ea@cap{%
\pingu@layer{foreground}[]
\pingu@block[rounded corners=.7mm]{\pingu@color@cap} ([xshift=.25mm]\pingu@name-wing-left-start) to[bend left=4] ([xshift=-\pingu@x@cap@padding]\pingu@name-wings-side-left) to[bend right=3]
([yshift=\pingu@x@cap@height]\pingu@name-head)
to[bend right=3]
([xshift=\pingu@x@cap@padding]\pingu@name-wings-side-right) [rounded corners=.15mm] to[bend left=4] ([xshift=-.25mm]\pingu@name-wing-right-start)
to[bend left=8]
([xshift=-\pingu@x@cap@padding]\pingu@name-wings-side-right)
[rounded corners=.15mm]
to[bend left=32] ++(\pingu@w@half+\pingu@x@cap@padding,\pingu@w@half+\pingu@one)
to[bend left=32] ++(\pingu@w@half+\pingu@x@cap@padding,-\pingu@w@half-\pingu@one)
to[bend left=8] cycle;
\endpingu@layer
}

\pingu@create@extra{constructionhelmet}{%
  construction helmet/.default      = pingu@yellow,
  construction helmet/.code         = \pingu@set@extra{constructionhelmet}{true}\pingu@color{constructionhelmet}{#1},
  construction helmet padding/.code = {\def\pingu@x@constructionhelmet@padding{#1}},
  construction helmet extra height/.code = {\def\pingu@x@constructionhelmet@height{#1}},
  construction helmet position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@constructionhelmet@angle{#1}\def\pingu@x@constructionhelmet@xshift{#2}\def\pingu@x@constructionhelmet@yshift{#3}\def\pingu@x@constructionhelmet@scale{#4}},
}{construction helmet padding=.325cm, construction helmet extra height=0pt,construction helmet position={-.5:(.05mm,-1.25mm)1}}

\newdimen\pingu@constructionhelmet@w@half \pingu@constructionhelmet@w@half=.85cm
\def\pingu@draw@ea@constructionhelmet{%
\scope[rotate around={\pingu@x@constructionhelmet@angle:(\pingu@name-head-top)},shift={(\pingu@name-head-top)},shift={(\pingu@x@constructionhelmet@xshift,\pingu@x@constructionhelmet@yshift)},scale=\pingu@x@constructionhelmet@scale]
\pingu@block{\pingu@color@constructionhelmet} (0,-.25cm)++(180:\pingu@constructionhelmet@w@half{} and \pingu@x@constructionhelmet@padding) arc (180:360:\pingu@constructionhelmet@w@half{} and \pingu@x@constructionhelmet@padding) arc (0:180:\pingu@constructionhelmet@w@half{} and .2cm) -- cycle;
\scope
\pingu@block{\pingu@color@constructionhelmet!93!pingu@black} (0,-.25cm)++(0:{.95\pingu@constructionhelmet@w@half} and .675cm) arc (0:180:{.95\pingu@constructionhelmet@w@half} and .675cm) coordinate[pos=.212] (@a) coordinate[pos=.256] (@aa) coordinate[pos=.788] (@b) coordinate[pos=.744] (@bb) arc (180:360:{.95\pingu@constructionhelmet@w@half} and .125cm) -- cycle;
\clip  (0,-.25cm)++(0:{.95\pingu@constructionhelmet@w@half} and .675cm) arc (0:180:{.95\pingu@constructionhelmet@w@half} and .675cm) arc (180:360:{.95\pingu@constructionhelmet@w@half} and .125cm) -- cycle;
\pingu@block{\pingu@color@constructionhelmet!99!pingu@black} (-.75mm,-.25cm-.125cm) to[bend left=1] ++ (0,.675cm+.125cm) -- ++(1.5mm,0) to[bend right=1] ++(0,-.675cm-.125cm) -- cycle;
\pingu@block{\pingu@color@constructionhelmet!99!pingu@black} (-.95mm,-.25cm-.125cm) to[bend left=3] ++ (-8mm,.675cm+.125cm) -- ++(1.5mm,0) to[bend right=3] ++(8mm,-.675cm-.125cm) -- cycle;
\pingu@block{\pingu@color@constructionhelmet!99!pingu@black} (-.55mm,-.25cm-.125cm) to[bend right=3] ++ (8mm,.675cm+.125cm) -- ++(1.5mm,0) to[bend left=3] ++(-8mm,-.675cm-.125cm) -- cycle;
\endscope
% get the 3d wobbles
\pingu@block[rounded corners=.03mm]{\pingu@color@constructionhelmet!99!pingu@black} (-.75mm,-.25cm+.675cm-.25mm) -- ++(0,.3mm) -| ++(1.5mm,-.3mm) -- cycle;
\pingu@block{\pingu@color@constructionhelmet!99!pingu@black} (@a) to[bend right=14] (@aa);
\pingu@block{\pingu@color@constructionhelmet!99!pingu@black} (@bb) to[bend right=14] (@b);
\endscope
}

\pingu@create@extra{conicalhat}{%
  conical hat/.default      = pingu@bronze,
  conical hat/.code         = \pingu@set@extra{conicalhat}{true}\pingu@color{conicalhat}{#1},
  conical hat rounding/.code = {\def\pingu@x@conicalhat@rounding{#1}},
  conical hat shade/.code = {\def\pingu@x@conicalhat@shade{#1}},
  conical hat height/.code = {\def\pingu@x@conicalhat@height{#1}},
  conical hat width/.code = {\def\pingu@x@conicalhat@width{#1}},
  conical hat position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@conicalhat@angle{#1}\def\pingu@x@conicalhat@xshift{#2}\def\pingu@x@conicalhat@yshift{#3}\def\pingu@x@conicalhat@scale{#4}},
}{conical hat position={-15:(2mm,-3mm)1}, conical hat height=8mm, conical hat width=2.25cm,conical hat shade=\pingu@color@conicalhat!80!pingu@black, conical hat rounding=.4pt}

\def\pingu@draw@ea@conicalhat{%
\scope[rotate around={\pingu@x@conicalhat@angle:(\pingu@name-head-top)},shift={(\pingu@name-head-top)},shift={(\pingu@x@conicalhat@xshift,\pingu@x@conicalhat@yshift)},scale=\pingu@x@conicalhat@scale]

\pingu@layer{background}[]
\pingu@block[rounded corners=\pingu@x@conicalhat@rounding]{\pingu@x@conicalhat@shade} (0,-.22cm)++(180:{\pingu@x@conicalhat@width/2+.05mm} and 1mm) coordinate (@) arc (180:360:{\pingu@x@conicalhat@width/2+.05mm} and 1mm) -- ++(.15mm,.3mm) to[bend right=5] ++(-\pingu@x@conicalhat@width/2, \pingu@x@conicalhat@height-.025cm) to[bend right=5] ([xshift=-.15mm,yshift=.3mm]@) -- cycle;
\endpingu@layer

\pingu@block[rounded corners=\pingu@x@conicalhat@rounding]{\pingu@color@conicalhat} (0,-.25cm)++(180:\pingu@x@conicalhat@width/2 and 1mm) coordinate (@) arc (180:0:\pingu@x@conicalhat@width/2 and 1mm) -- ++(.225mm,.6mm) to[bend right=5] ++(-\pingu@x@conicalhat@width/2, \pingu@x@conicalhat@height) to[bend right=5] ([xshift=-.225mm,yshift=.6mm]@) -- cycle;
\endscope
}

\pingu@create@extra{witchhat}{%
  witch hat/.code      = \pingu@set@extra{witchhat}{true}\pingu@color{witchhat}{#1},
  witch hat/.default   = pingu@purple!40!black,
  witch hat base/.code = \pingu@color{witchhat@base}{#1},
  witch hat coronal/.code = \pingu@color{witchhat@coronal}{#1},
  witch hat ribbon/.code = \pingu@color{witchhat@ribbon}{#1},
  witch hat band/.code = \pingu@color{witchhat@band}{#1},
  witch hat position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@witchhat@angle{#1}\def\pingu@x@witchhat@xshift{#2}\def\pingu@x@witchhat@yshift{#3}\def\pingu@x@witchhat@scale{#4}},
}{witch hat position={-7:(.625mm,.45mm){1.15}},witch hat base=\pingu@color@witchhat,witch hat coronal=\pingu@color@witchhat!91!white,witch hat ribbon=\pingu@color@witchhat!87!white,witch hat band=!hide}

\newdimen\pingu@witchhat@w@half \pingu@witchhat@w@half=1.125cm
\newdimen\pingu@witchhat@h \pingu@witchhat@h=1.3cm
\def\pingupathwitchhatupper{[rounded corners=.65mm](-.625cm,-.25cm) -- ++(.8cm,\pingu@witchhat@h-4.5mm) -- ++(6.5mm,4.5mm) -- ++(-1.5mm,-4.5mm) -- ++(-1.25mm,-\pingu@witchhat@h+4.5mm)}
\def\pingu@draw@ea@witchhat{%
\scope[rotate around={\pingu@x@witchhat@angle:(\pingu@name-head-top)},shift={(\pingu@name-head-top)},shift={(\pingu@x@witchhat@xshift,\pingu@x@witchhat@yshift)},scale=\pingu@x@witchhat@scale]
\pingu@draw[semithick]{\pingu@color@witchhat@band} (-.615cm,-.25cm) to[out=-100,in=180] ++(.5cm,-1.1cm) to[bend right=5] ++(3.5mm,.1mm) to[out=0,in=-78] ++(.433cm,1.1cm);
\pingu@block[/pingu/@draw=\pingu@color@witchhat@coronal,thick]{\pingu@color@witchhat@base} (0,-.25cm)++(180:\pingu@witchhat@w@half{} and .15cm) arc (180:360:\pingu@witchhat@w@half{} and .15cm) arc (0:180:\pingu@witchhat@w@half{} and .115cm) -- cycle;
\pingu@block{\pingu@color@witchhat} \pingupathwitchhatupper;
\clip\pingupathwitchhatupper;
\pingu@block{\pingu@color@witchhat@ribbon} (\z@,.2mm) ellipse [x radius=.95\pingu@witchhat@w@half, y radius=.12cm];
\pingu@block{\pingu@color@witchhat} (\z@,.134cm) ellipse [x radius=.95\pingu@witchhat@w@half, y radius=.12cm];
\endscope
}


\pingu@create@extra{mitra}{%
  mitra/.default     = pingu@red!67!pingu@black,%pingu@black!90!black,
  mitra/.code        = \pingu@set@extra{mitra}{true}\pingu@color{mitra}{#1},
  mitra height/.code = {\def\pingu@x@mitra@height{#1}},
  mitra background/.code = \pingu@color{mitra@background}{#1},
  mitra overset/.code = {\def\pingu@x@mitra@overset{#1}},
  mitra lower angle/.code = {\def\pingu@x@mitra@lowerangle{#1}},
  mitra upper angle/.code = {\def\pingu@x@mitra@upperangle{#1}},
  mitra lower band/.code = \pingu@color{mitra@lower@band}{#1},
  mitra lower band height/.code = {\def\pingu@x@mitra@lowerband@height{#1}},
  mitra upper band/.code = \pingu@color{mitra@upper@band}{#1},
  mitra upper band height/.code = {\def\pingu@x@mitra@upperband@height{#1}},
  mitra center band/.code = \pingu@color{mitra@center@band}{#1},
  mitra center band width/.code = {\def\pingu@x@mitra@centerband@width{#1}},
  mitra position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@mitra@angle{#1}\def\pingu@x@mitra@xshift{#2}\def\pingu@x@mitra@yshift{#3}\def\pingu@x@mitra@scale{#4}},
}{mitra position={0:(0,0)1},mitra height=1.125cm,mitra overset=1.25mm,mitra lower angle=125,mitra upper angle=-35,mitra lower band=pingu@yellow!75!pingu@black,mitra center band=\pingu@color@mitra@lower@band,mitra lower band height=.2,mitra center band width={2*\pingu@x@mitra@lowerband@height},mitra upper band=\pingu@color@mitra@lower@band,mitra upper band height={1.5*\pingu@x@mitra@lowerband@height},mitra background=\pingu@color@mitra!80!pingu@black}

\newdimen\pingu@mitra@w@half \pingu@mitra@w@half=.625cm
\def\pingu@x@mitra@path{(0,-.2185cm)++(180:\pingu@mitra@w@half{} and .035cm) arc (180:360:\pingu@mitra@w@half{} and .035cm) [rounded corners=1pt] -- ++(\pingu@x@mitra@overset,.3*\pingu@x@mitra@height) to[out=\pingu@x@mitra@lowerangle,in=\pingu@x@mitra@upperangle] ++(-\pingu@x@mitra@overset-\pingu@mitra@w@half,.7*\pingu@x@mitra@height)
to[out=180-\pingu@x@mitra@upperangle,in=180-\pingu@x@mitra@lowerangle] ++(-\pingu@x@mitra@overset-\pingu@mitra@w@half,-.7*\pingu@x@mitra@height) [sharp corners]  -- cycle}
\def\pingu@draw@ea@mitra{%
\scope[rotate around={\pingu@x@mitra@angle:(\pingu@name-head-top)},shift={(\pingu@name-head-top)},shift={(\pingu@x@mitra@xshift,\pingu@x@mitra@yshift)},scale=\pingu@x@mitra@scale]
\pingu@block{\pingu@color@mitra@background} (0,-.2185cm)++(180:\pingu@mitra@w@half{} and .035cm) arc (180:360:\pingu@mitra@w@half{} and .035cm) [rounded corners=1pt] -- ++(\pingu@x@mitra@overset,.3*\pingu@x@mitra@height) to[out=\pingu@x@mitra@lowerangle,in=\pingu@x@mitra@upperangle] ++(-\pingu@x@mitra@overset-\pingu@mitra@w@half-.66mm,.7*\pingu@x@mitra@height-.1mm)
to[out=180-\pingu@x@mitra@upperangle+2,in=180-\pingu@x@mitra@lowerangle-2] ++(-\pingu@x@mitra@overset-\pingu@mitra@w@half+.66mm,-.7*\pingu@x@mitra@height+.1mm) [sharp corners]  -- cycle;
\pingu@block{\pingu@color@mitra} \pingu@x@mitra@path;
% \pingu@block{\pingu@color@mitra} \pingupathmitraupper;
\scope\clip\pingu@x@mitra@path;
% TODO: switch to factors non relative to \pingu@x@mitra@overset
\pingu@block{\pingu@color@mitra@lower@band} (0,-.2185cm)++(180:\pingu@mitra@w@half{} and .035cm) arc (180:360:\pingu@mitra@w@half{} and .035cm) -- ++(\pingu@x@mitra@lowerband@height*\pingu@x@mitra@overset,\pingu@x@mitra@lowerband@height*.3*\pingu@x@mitra@height) arc (0:-180:{\pingu@x@mitra@lowerband@height*\pingu@x@mitra@overset+\pingu@mitra@w@half} and .035cm)  -- cycle;
\pingu@block{\pingu@color@mitra@center@band} (\pingu@x@mitra@centerband@width*\pingu@x@mitra@overset+.1mm,-.2185cm) to[bend right=4] ++(0,\pingu@x@mitra@height) to[bend right] ++(-2*\pingu@x@mitra@centerband@width*\pingu@x@mitra@overset-.1mm,0) to[bend left=4] ++(0,-\pingu@x@mitra@height) -- cycle;
\pingu@block{\pingu@color@mitra@upper@band} (0,.3*\pingu@x@mitra@height-.2185cm-0.5*\pingu@x@mitra@upperband@height*.3*\pingu@x@mitra@height)++(180:{\pingu@x@mitra@overset+\pingu@mitra@w@half} and .035cm) arc (180:360:{\pingu@x@mitra@overset+\pingu@mitra@w@half} and .035cm) -- ++(0,\pingu@x@mitra@upperband@height*.3*\pingu@x@mitra@height) arc (0:-180:{\pingu@x@mitra@overset+\pingu@mitra@w@half} and .035cm)  -- cycle;
\endscope\endscope}