The TikZpingus package
Internals
C.12 The Bends¶
to[bend right=<angle>] is expensive, so all body bends use precomputed control points:
% |to[bend right=<angle>]| re-derives its control points on every use. As all
% body bends are vertical and their angle is known at load time, the two
% factors yielding the same control points are computed once instead.
\def\pingu@bend@factor{.3899534}
% #1 macro to define | #2 angle, as given to |bend right|
\def\pingu@newbend#1#2{%
\pgfmathsetmacro\pingu@bend@x{\pingu@bend@factor*sin(#2)}%
\pgfmathsetmacro\pingu@bend@y{\pingu@bend@factor*cos(#2)}%
\edef#1##1{\noexpand\pingu@bend@v{\pingu@bend@x}{\pingu@bend@y}{##1}}%
}
% #1 x factor | #2 y factor | #3 signed height of the segment
\def\pingu@bend@v#1#2#3{.. controls +({#1*(#3)},{#2*(#3)}) and +({#1*(#3)},{-#2*(#3)}) .. ++(0,#3)}
\pingu@newbend\pingu@bend@body{\pingu@bend}
\pingu@newbend\pingu@bend@belly{.8*\pingu@bend}
\pingu@newbend\pingu@bend@chubby{1.65*\pingu@bend}
\pingu@newbend\pingu@bend@legacy{1.25*\pingu@bend}