Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color handling #148

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions doc/tikzpingus-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
{\\pingu@draw}{{\doccmd{pingu@draw}}}{11}
{\\@pingu@none}{{\graycmd{@pingu@none}}}{11}
{\\path}{{\graycmd{path}}}5
{\\definecolor}{{\doccmd{definecolor}}}{12}
{\\pgfqkeys}{{\graycmd{pgfqkeys}}}9
{\\@ifnextchar}{{\graycmd{@ifnextchar}}}9
{\\csname}{{\graycmd{csname}}}6
Expand Down Expand Up @@ -4995,7 +4996,14 @@ \subsubsection{The second shirt}
\newcommand\includecode[2][../tex/tikzpingus.sty]{\lstinputlisting[linerange=#2-@#2,style=lstpingu,language=pinguinternallang,numbers=left,numberstyle={\tiny\color{gray}\sffamily},numbersep=5pt]{#1}}
\def\current@indexfile{\jobname-internals}
% gobble leading pingu for indexing
\def\@gobblekey#1{\IfBeginWith{#1}{pingu@}{\StrDel[1]{#1}{pingu@}[#1]\protected@xdef#1{#1}}{}}
\def\@gobblekey#1{%
\IfBeginWith{#1}{pingu@}{%
\StrDel[1]{#1}{pingu@}[#1]\protected@xdef#1{#1}%
}{%
\IfBeginWith{#1}{@pingu@}{%
\StrDel[1]{#1}{@pingu@}[#1]\protected@xdef#1{#1}%
}{}%
}}
\newsavebox\warningpengu
\setbox0=\hbox{\tikz{\pingu[wings shock,eyes shock,small]}}
\setbox\warningpengu=\hbox{\tikz{\node[scale=.35] (a) at(0,0) {\box0}; \node[above] at(a.north) {\faExclamation};}}
Expand All @@ -5014,18 +5022,24 @@ \subsection{General commands}
Do not change this dimension as it represents one milli meter as the base unit.
\end{commandexplain}

\subsubsection{Color}
\subsubsection{Color Management}
There is not a lot of magic in the color handling of this package.

\begin{commandexplain}{pingu@color}{\mand{name}\mand{color}}
Creates a macro \cmd{pingu@color@<name>} that links to the given color:
\includecode{pingu@color}
I decided against the usage of \cmd{colorlet}, to support \cmdref{@pingu@none}
I decided against the usage of \cmd{colorlet}, to support \cmdref{@pingu@none} and dynamic redefinition of the colors.
\end{commandexplain}

\begin{commandexplain}{@pingu@none}{}
Holds the special color to hide the drawing of specific components as described within \autoref{Colors} (holds the value: \@pingu@none).
Holds the special color to hide the drawing of specific components as described within \autoref{Colors} (holds the value: \say{\@pingu@none}).
If you redefine this command, you redefine this hidden color. Hover, if done outside of the preamble, this may result in weird side effects due to expansions.
\end{commandexplain}

As shown in \autoref{Colors}, this is the definition of the colors, with the helper-macro \cmddef{@pingu@color@}, which i created solely for me editor to highlight the colors accordingly:
\includecode{color\ definitions}


\subsubsection{Selections}
TODO: explain selections

Expand Down Expand Up @@ -5088,6 +5102,6 @@ \subsection{Adding new Eyes}
\lstset{breakatwhitespace}
\indexprologue{\label{normal-idx}This index shows all of the options and commands that a normal user of the package may use! See the \hyperref[internal-idx]{\indexinternalsoverviewname} for an overview of keys and commands used behind the scenes.}
\printindex[\jobname]
\indexprologue{\label{internal-idx}The initial \cmd{pingu@} is ignored for indexing.}
\indexprologue{\label{internal-idx}The initial \cmd{pingu@} and \cmd{@pingu@} is ignored for indexing (as this would destroy the whole sense of the index).}
\printindex[\jobname-internals]
\end{document}
17 changes: 9 additions & 8 deletions tex/tikzpingus.sty
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
\pgfsetlayers{very-background,background,main,middle,foreground}
\fi
% #region whole setup
% #region colors

% <color definitions>
\def\@pingu@color@ #1#2(#3,#4,#5){\definecolor{pingu@#1}{#2}{#3,#4,#5}}
\@pingu@color@{main}RGB(3,14,29)
\@pingu@color@{black}RGB(23,19,19)
Expand All @@ -35,7 +36,7 @@
\@pingu@color@{red}RGB(217, 40, 28)
\@pingu@color@{purple}RGB(244,48,93)
\def\@pingu@none{!hide}
% #endregion
% <@color definitions>

% #region lengths and dimens
\newdimen\pingu@one@eight \pingu@one@eight=.125cm % constants to save tokens
Expand Down Expand Up @@ -607,9 +608,9 @@ coordinate[pos=\pinguanglehl] (\pingu@name-head-left);
\pingu@lefteye@add{#1}{#2}\pingu@righteye@add{#1}{#3}%
}
\pgfqkeys{/pingu}{%
eyes none/.style={eyes=none},
left eye none/.style={left eye=none},
right eye none/.style={right eye=none}
eyes none/.style = {eyes=none},
left eye none/.style = {left eye=none},
right eye none/.style = {right eye=none}
} % adding the alias
% <@pingu@eyes@s>

Expand Down Expand Up @@ -685,8 +686,8 @@ coordinate[pos=\pinguanglehl] (\pingu@name-head-left);
% name core | left | right | above: \iftrue | angle for items | wing down [left]
\long\def\@pingu@wings@s#1#2#3#4#5#6{%
\pgfqkeys{/pingu}{%
left wing #1/.style = {/pingu/left wing={#1}, /pingu/left wing color={##1}},%
left wing #1/.default = \pingu@color@body@main,%
left wing #1/.style = {/pingu/left wing={#1}, /pingu/left wing color={##1}},%
left wing #1/.default = \pingu@color@body@main,%
right wing #1/.style = {/pingu/right wing={#1}, /pingu/right wing color={##1}},%
right wing #1/.default = \pingu@color@body@main,%
wings #1/.style = {/pingu/wings={#1}, /pingu/wings color={##1}},%
Expand Down Expand Up @@ -1137,7 +1138,7 @@ coordinate[pos=\pinguanglehl] (\pingu@name-head-left);
\pingu@block{\pingu@color@sheriffstar!98!pingu@black} (@.outer point \i) circle [radius=.2mm];
}

\node[,outer sep=0pt,inner xsep=0pt,inner ysep=.25mm] (@s) at (@) {\ifx\pingu@color@sheriffstar@lines\@pingu@none\else\color{\pingu@color@sheriffstar@lines}\fi\pingu@x@sheriff@star@content};
\node[outer sep=0pt,inner xsep=0pt,inner ysep=.25mm] (@s) at (@) {\ifx\pingu@color@sheriffstar@lines\@pingu@none\else\color{\pingu@color@sheriffstar@lines}\fi\pingu@x@sheriff@star@content};
\pingu@draw[line width=.002mm]{\pingu@color@sheriffstar@lines} (@s.north east) -- (@s.north west);
\pingu@draw[line width=.002mm]{\pingu@color@sheriffstar@lines} (@s.south east) -- (@s.south west);
\endpingu@layer}
Expand Down