tikz.dev / TikZpingus Manual

The TikZpingus package

Internals

C.5 The Eyes

C.5.1 Important Commands

\pingu@eye@shift

This dimension holds a hardcoded value to be used as the offset for eyes. Its default value is 2.27621pt. It may be removed in the future (or replaced by an option).

C.5.2 The Code

The eyes of the penguin are controlled by two selections for the left, and the right eye. Because we always want the coordinates for the right and the left eye (as presented in Section 2.1), the none-version of \pingu@create@selection creates those:

\pingu@create@selection{lefteye}{%
\path ([yshift=.75mm,xshift=\pingu@eye@shift]\pingu@name-eye-back-left)
coordinate (\pingu@name-eye-left);%
}
\pingu@create@selection{righteye}{%
\path ([yshift=.75mm,xshift=-\pingu@eye@shift]\pingu@name-eye-back-right)
coordinate (\pingu@name-eye-right);%
}

With this code, we define the six following commands: \pingu@lefteye@select, \pingu@lefteye@add, \@pingu@drawer@lefteye@, \pingu@righteye@select, \pingu@righteye@add, and \@pingu@drawer@righteye@.

Within the initialization of all penguin options, we use these commands. Furthermore, /pingu/eyes acts as a comfort option which operates on both selectors:

left eye/.code = \pingu@lefteye@select{#1},
left eye color/.code = \pingu@color{eye@left}{#1},
left eye second color/.code = \pingu@color{eye@second@left}{#1},
right eye/.code = \pingu@righteye@select{#1},
right eye color/.code = \pingu@color{eye@right}{#1},
right eye second color/.code = \pingu@color{eye@second@right}{#1},
eyes/.style = {
/pingu/left eye = {#1},
/pingu/right eye = {#1}
},
eyes color/.style = {
/pingu/left eye color = {#1},
/pingu/right eye color = {#1}
},
eyes second color/.style = {
/pingu/left eye second color = {#1},
/pingu/right eye second color = {#1}
},

Both eyes have two colors to work with: \pingu@color@eye@left, \pingu@color@eye@second@left for the left as well as \pingu@color@eye@right and \pingu@color@eye@second@right for the right eye.

C.5.3 Adding new Eyes

Now on how to add new eyes. While it is possible to use \pingu@lefteye@add and \pingu@righteye@add, setting up the corresponding “eye” and “eyes” comfort-methods is rather tedious. For this, i created the command \pingu@eyes@s…

\pingu@eyes@s{⟨name⟩}{⟨left-eye⟩}{⟨right-eye⟩}[default color=pingu@black]

Allows to easily add new eyes.

Important:

Your code for the eyes must create the coordinates \pingu@name-eye-left and \pingu@name-eye-right respectively. This is not checked! It is recommended to use the coordinates \pingu@name-eye-back-left and \pingu@name-eye-back-right for reference.

The macro \pingu@eyes@s is defined with the help of \pingu@eyes@s@ like this:

\long\def\pingu@eyes@s#1#2#3{%
\@ifnextchar[%
{\pingu@eyes@s@{#1}{#2}{#3}}%
{\pingu@eyes@s@{#1}{#2}{#3}[pingu@black]}%
}
\long\def\pingu@eyes@s@#1#2#3[#4]{%
\pgfqkeys{/pingu}{%
left eye #1/.style = {/pingu/left eye={#1}, /pingu/left eye color={##1}},
left eye #1/.default = {#4},
right eye #1/.style = {/pingu/right eye={#1}, /pingu/right eye color={##1}},
right eye #1/.default = {#4},
eyes #1/.style = {/pingu/eyes={#1}, /pingu/eyes color={##1}},
eyes #1/.default = {#4}
}%
\pingu@lefteye@add{#1}{#2}\pingu@righteye@add{#1}{#3}%
}

As an example, this is the definition of the “normal eyes” (/pingu/eyes normal) in the code:

\pingu@eyes@s{normal}{%
\pingu@block{\pingu@color@eye@left}
([yshift=.75mm,xshift=\pingu@eye@shift]\pingu@name-eye-back-left)
coordinate (\pingu@name-eye-left)
ellipse [x radius=.1225cm, y radius=.1365cm];
}{%
\pingu@block{\pingu@color@eye@right}
([yshift=.75mm,xshift=-\pingu@eye@shift]\pingu@name-eye-back-right)
coordinate(\pingu@name-eye-right)
ellipse [x radius=.1225cm, y radius=.1365cm];
}

As another example, this is the definition of the “shiny eyes” (/pingu/eyes shiny):

\pingu@eyes@s{shiny}{%
\pingu@block{\pingu@color@eye@left}
([yshift=.75mm,xshift=\pingu@eye@shift]\pingu@name-eye-back-left)
coordinate(\pingu@name-eye-left)
ellipse [x radius=.22cm, y radius=.26cm];
\pingu@block{\pingu@color@eye@second@left}
(\pingu@name-eye-left)++(\eyebaseang:.85mm and \pingu@one)
ellipse [x radius=.8mm, y radius=\pingu@one];
\pingu@block{\pingu@color@eye@second@left}
(\pingu@name-eye-left)++(\eyebaseang+180:.12cm and .14cm)
ellipse [x radius=.25mm, y radius=.35mm];
}{%
\pingu@block{\pingu@color@eye@right}
([yshift=.75mm,xshift=-\pingu@eye@shift]\pingu@name-eye-back-right)
coordinate(\pingu@name-eye-right)
ellipse [x radius=.22cm, y radius=.26cm];
\pingu@block{\pingu@color@eye@second@right}
(\pingu@name-eye-right)++(\eyebaseang:.85mm and \pingu@one)
ellipse [x radius=.8mm, y radius=\pingu@one];
\pingu@block{\pingu@color@eye@second@right}
(\pingu@name-eye-right)++(\eyebaseang+180:.12cm and .14cm)
ellipse [x radius=.25mm, y radius=.35mm];
}

The usage of \eyebaseang is outdated and will probably be removed in the future.