% Florian Sihler, 2022
% Licensed under GNU General Public License version 3
% https://opensource.org/licenses/gpl-3.0.html
% TODO: integrate?
% TODO: allow to specify rotation anchor

\pingu@create@extra{bee}{%
    bee/.code    	  = {\pingu@set@extra{bee}{true}\pingu@color{bee}{#1}},
    bee/.default      = pingu@yellow!60!pingu@white,%
    bee body/.code    = \pingu@color{bee@body}{#1},
    bee eyes/.code    = \pingu@color{bee@eyes}{#1},
    bee wings/.code    = \pingu@color{bee@wings}{#1},
    bee mouth/.code    = \pingu@color{bee@mouth}{#1},
    bee blush/.code    = \pingu@color{bee@blush}{#1},
    bee position/.code args  = {#1:(#2,#3)#4}{\def\pingu@x@bee@angle{#1}\def\pingu@x@bee@xshift{#2}\def\pingu@x@bee@yshift{#3}\def\pingu@x@bee@scale{#4}},
}{bee body=pingu@black!82!gray,bee wings=pingu@blue!8!pingu@white,bee mouth=\pingu@color@bee@body,bee eyes=\pingu@color@bee@body,bee blush=pingu@red!21!\pingu@color@bee,bee position={-27.5:(8mm,15mm){.875}}}

\def\pingu@bee@x@lbody{ (left) to[out=270,in=150] (0,-.725) to[out=30,in=270] (right)}

\def\pingu@draw@ea@bee{%
\scope[very path/.append style={line join=round},rotate around={\pingu@x@bee@angle:(\pingu@name-head)},shift={(\pingu@name-head)},shift={(\pingu@x@bee@xshift,\pingu@x@bee@yshift)},scale=\pingu@x@bee@scale]
% wings
\coordinate (wl) at(20:2.55mm);
\coordinate (wr) at(160:2.55mm);
\pingu@draw[fill=\pingu@color@bee@wings!80!white,rotate around=-32:(wl)]{\pingu@color@bee@body} (wl) ellipse [x radius=6.15mm, y radius=2.75mm];
\pingu@draw[fill=\pingu@color@bee@wings!80!white,rotate around=32:(wr)]{\pingu@color@bee@body} (wr) ellipse [x radius=6.15mm, y radius=2.75mm];
\pingu@draw[fill=\pingu@color@bee@wings,rotate around=19:(wl)]{\pingu@color@bee@body} (wl) ellipse [x radius=6.55mm, y radius=3.125mm];
\pingu@draw[fill=\pingu@color@bee@wings,rotate around=-19:(wr)]{\pingu@color@bee@body} (wr) ellipse [x radius=6.55mm, y radius=3.125mm];
% body
\path (-.375,0) coordinate (left) -- (.375,0) coordinate (right);
% TODO: block draw?
\pingu@block[draw=\pingu@color@bee@body]{\pingu@color@bee@body} \pingu@bee@x@lbody;
\scope\clip\pingu@bee@x@lbody;
\foreach \angl in {30,1} {
\pingu@block{\pingu@color@bee} (-\angl:.75) to[bend left=14] (180+\angl:.75) -- ++(0,-1.75mm)
                     to[bend right=14] (-\angl-14:.75) -- cycle;
}\endscope
% left and right arm
\foreach\m/\s/\k in {right/-2.45/95,left/-.75/80} {
\scope[shift=(\m),yshift=\s,rotate around=\k:(\m),scale=.166]
\pingu@block{\pingu@color@bee@body} (-.965,0) arc(270:90:.29) -- ++(1.233,0) arc (90:-90:.29) -- cycle;
\endscope}
% sting
\pingu@draw[line cap=round,thick]{\pingu@color@bee@body} (0,-.725) -- ++(0,-.035);
% head
\pingu@draw[fill=\pingu@color@bee,rounded corners=1.5pt]{\pingu@color@bee@body} (.85mm,-.55mm) to[bend right=30,looseness=.9] ([xshift=1.45mm,yshift=1.35mm]right) arc(0:180:{(.75cm+2*1.45mm)/2} and {(.75cm+2*1.45mm)/2.05}) to[bend right=30,looseness=.9] (-.85mm,-.55mm) -- cycle;
% eyes [intersect with left and right]
\pingu@block{\pingu@color@bee@eyes} (left|-0,2.265mm)++(.6mm,0) coordinate (el) circle[radius=.6mm];
\coordinate (ell) at ([yshift=-.8mm]el);
\pingu@block[rotate around=3:(ell)]{\pingu@color@bee@blush} ([yshift=-.8mm]el) ellipse[x radius=.412mm, y radius=.165mm];
\pingu@block{\pingu@color@bee@eyes} (right|-0,2.265mm)++(-.6mm,0) coordinate (er) circle[radius=.6mm];
\coordinate (err) at ([yshift=-.8mm]er);
\pingu@block[rotate around=-1:(err)]{\pingu@color@bee@blush} ([yshift=-.8mm]er) ellipse[x radius=.4mm, y radius=.155mm];
% mouth
\scope[yshift=1mm]
\pingu@draw[semithick,line cap=round]{\pingu@color@bee@mouth} (-.6mm,0) arc (180:360:.6mm and .415mm);
% antenna
\pingu@draw[line cap=round]{\pingu@color@bee@body} (123:4mm) to[out=110,in=-41] ++(-1mm,3mm) coordinate (@);
\pingu@block[rotate around=-41:(@)]{\pingu@color@bee@body} ([xshift=-.1mm,yshift=-.185mm]@) ellipse[x radius=.55mm,y radius=.35mm];
\pingu@draw[line cap=round]{\pingu@color@bee@body} (57:4mm) to[out=70,in=180+41] ++(1mm,3mm) coordinate (@);
\pingu@block[rotate around=41:(@)]{\pingu@color@bee@body} ([xshift=-.1mm,yshift=-.2mm]@) ellipse[x radius=.55mm,y radius=.35mm];
\endscope
\endscope
}