% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
aobs-tikz - TikZ auxiliary styles for Beamer overlays

E-mail: claudio dot fiandrino at gmail dot com

Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The package defines auxiliary TikZ styles useful for
overlaying pictures' elements in Beamer.

The TikZ styles are grouped in a library, overlay-beamer-styles
which is automatically called by the aobs-tikz package. Users 
can either load only aobs-tikz or the library; the latter method 
necessitates TikZ manual load.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
aobs-tikz - TikZ auxiliary styles for Beamer overlays

E-mail: claudio dot fiandrino at gmail dot com

Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

The package defines auxiliary TikZ styles useful for
overlaying pictures' elements in Beamer.

The TikZ styles are grouped in a library, overlay-beamer-styles
which is automatically called by the aobs-tikz package. Users 
can either load only aobs-tikz or the library; the latter method 
necessitates TikZ manual load.
\endpreamble
\postamble

Copyright (C) 2024 by Claudio Fiandrino <claudio.fiandrino@gmail.com>

This file may be distributed and/or modified under the conditions
of the LaTeX Project Public License, either version 1.3 of this
license or (at your option) any later version.
The latest version of this license is in:

   http://www.latex-project.org/lppl.txt

and version 1.3 or later is part of all distributions of LaTeX
version 2005/12/01 or later.

This work is "maintained" (as per LPPL maintenance status) by
Claudio Fiandrino.

This work consists of the files  aobs-tikz.dtx
and the derived files  aobs-tikz.ins
                                 aobs-tikz.sty
                                 tikzlibrarybeamer-overlay-styles.code.tex
                                 aobs-tikz.pdf
                                 example.tex 
                                 example.pdf
                                 README.txt

\endpostamble
\generate{\file{tikzlibraryoverlay-beamer-styles.code.tex} {\from{\jobname.dtx}{tikzlibrary}}}
\generate{\file{example.tex} {\from{\jobname.dtx}{example}}}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\generate{
   \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aobs-tikz}[2024/04/15 v1.01 Auxiliary TikZ styles for picture overlay in Beamer]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{charter,pxfonts}
\RequirePackage[dvipsnames]{xcolor}%
\definecolor{Eored}{rgb}{.647,.129,.149}
\definecolor{Eogreen}{rgb}{0,0.53,0}
\convertcolorspec{cmyk}{0.94,0.53,0,0}{rgb}\Eoblue
\definecolor{Eoblue}{rgb}{\Eoblue}
\usepackage{listings}
\lstset{language=[LaTeX]Tex,
    keywordstyle=\color{Eored},
    texcsstyle=*\color{Eored},
    basicstyle=\footnotesize\ttfamily,
    commentstyle=\footnotesize\color{Eogreen}\rmfamily,
    stringstyle=\footnotesize\rmfamily,
    showstringspaces=false,
    morekeywords={usetikzlibrary,node,tikzset,tikzstyle,
     path,draw,foreach,pgfmathsetmacro,tikz},
    literate=
            *{\{}{{{\color{Eoblue}{\{}}}}{1}
            {\}}{{{\color{Eoblue}{\}}}}}{1}
            {(}{{{\color{Eoblue}{(}}}}{1}
            {)}{{{\color{Eoblue}{)}}}}{1}
            {[}{{{\color{Eoblue}{[}}}}{1}
            {]}{{{\color{Eoblue}{]}}}}{1}
            {!}{{{!}}}{1},   
}

\usepackage{hypdoc}
\newcommand\aobstikz{\textsf{aobs-tikz}}
\newcommand\aobstikzversion{1.01}
\newcommand\aobstikzdate{\today}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{101}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.1}{2013/12/19}{Initial version}
% \changes{v0.2}{2013/12/23}{Path aspects}
% \changes{v0.2}{2024/04/15}{Thanking Matthew}
%
% \GetFileInfo{aobs-tikz.sty}
%
% \title{The \aobstikz{} package\thanks{This document
% corresponds to \textsf{aobs-tikz}~v\aobstikzversion,
% dated~\aobstikzdate. It is released under and subject to the latest version of the \href{http://www.latex-project.org/lppl/}{\LaTeX\ Project Public License (LPPL)}.}}
% \author{Claudio Fiandrino \\ \footnotesize\href{mailto:claudio.fiandrino@gmail.com}{claudio.fiandrino@gmail.com}}
% \maketitle
% 
% \begin{abstract}
% The package provides auxiliary styles helpful for drawing overlayed pictures in Beamer. These styles should be intended as extension of the previous work shown by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} of \href{http://tex.stackexchange.com}{TeX.SX} in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)} which, in turn, is based on the work of \href{https://tex.stackexchange.com/users/1402/matthew-leingang}{Matthew Leingang} in \href{https://tex.stackexchange.com/a/6155/13304}{How to make beamer overlays with Tikz node}. 
% \end{abstract}
% \tableofcontents
%\section{Introduction}
% The aim of \aobstikz{} is to provide users simple tools to create overlayed-aware pictures for Beamer presentations. A set of new TikZ styles, grouped within a library, has been define on purpose.
%
% The library is proposed as extension of the previous work by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} on \href{www.tex-stackexchange.com}{TeX.SX}, illustrated in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)} which, in turn, is based on the work of \href{https://tex.stackexchange.com/users/1402/matthew-leingang}{Matthew Leingang} in \href{https://tex.stackexchange.com/a/6155/13304}{How to make beamer overlays with Tikz node}. The very first version of the library has been implemented for answering the question \href{http://tex.stackexchange.com/q/84513/13304}{Highlighting in Beamer using TikZ nodes}: \aobstikz{} further extends and improves the original styles. 
%
% The main advantage of using the new styles is that they automatically prevent the so called \emph{jumping-effect} which occasionally happen with Beamer. 
%
% \section{The new styles}
% The new styles can create overlays by altering the colors and the aspect of pictures' elements. 
% Usually, to create an animation, the elements have to appear or disapper, the shading, the fill or the border color should change. To achieve this goal, three features have to be specified: the normal behavior, the modified behaviour and the moments in which the modified behaviour takes place. \aobstikz{} defines TikZ styles for these three features accordingly . For example, to alter the shape filling, it is possible to exploit:
% \begin{itemize}
% \item \texttt{background default fill=<\textit{style}>}: the style used for default behaviour;
% \item \texttt{background fill=<\textit{style}>}: the style used for the modified behaviour;
% \item \texttt{fill on=<\textit{overlay specifications}>}: moments in which the modified behaviour is activated.
% \end{itemize}
% The new styles can alter the following TikZ properties:
% \begin{itemize}
% \item \emph{fill};
% \item \emph{draw};
% \item \emph{filldraw};
% \item \emph{text};
% \item path aspect, including thickness, double line and pattern (solid, dashed, dotted, etc\ldots);
% \item \emph{shade};
% \item \emph{shadedraw}.
% \end{itemize}
% \DescribeMacro{draw}^^A
% To alter the border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default draw=<\textit{style}>};
% \item \texttt{background draw=<\textit{style}>};
% \item \texttt{draw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{filldraw}^^A
% To alter the both filling and border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
% \item \texttt{background filldraw=<\textit{\textcolor{orange}{border-col} filled by \textcolor{orange}{fill-col}}>};
% \item \texttt{filldraw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{text}^^A
% To alter the \texttt{text} color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default text=<\textit{style}>};
% \item \texttt{background text=<\textit{style}>};
% \item \texttt{text on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{path aspect}^^A
% To alter the path aspect, the following options are available:
% \begin{itemize}
% \item \texttt{background default aspect=<\textit{style}>};
% \item \texttt{background aspect=<\textit{style}>};
% \item \texttt{aspect on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{shade}^^A
% To alter the shading properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default shade=<\textit{style}>};
% \item \texttt{background shade=<\textit{style}>};
% \item \texttt{shade on=<\textit{overlay specifications}>}.
% \end{itemize}
% \DescribeMacro{shadedraw}^^A
% To alter both filling and border color properties, the following options are available:
% \begin{itemize}
% \item \texttt{background default shadedraw=<\textit{style}>};
% \item \texttt{background shadedraw=<\textit{style}>};
% \item \texttt{shadedraw on=<\textit{overlay specifications}>}.
% \end{itemize}
% \StopEventually{\PrintChanges}
% \section{Implementation}
% \subsection{Package}
%
% \iffalse
%<*package>
% \fi
% The package itself loads only TikZ and the library \texttt{overlay-beamer-styles}.
%    \begin{macrocode}
\RequirePackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
%    \end{macrocode} 
% \iffalse
%</package>
% \fi
% \iffalse
%<*tikzlibrary>
% \fi
% \subsection{TikZ Library}
% The core of the package is the TikZ library \texttt{overlay-beamer-styles}. The first style defined is \texttt{visible on} based on prior work by user \href{http://tex.stackexchange.com/users/3751/daniel}{Daniel} of \href{http://tex.stackexchange.com}{TeX.SX} in \href{http://tex.stackexchange.com/q/55806/13304}{Mindmap tikzpicture in beamer (reveal step by step)}. The original style has been enforced to make it working also in presence of opaque text.
%    \begin{macrocode}
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

\tikzset{
  background text/.style={text=#1},
  background text/.default={black},
  background default text/.style={
    background text/.default={#1},
  },
  text on/.style={alt=#1{}{background text}},
}

\tikzset{
  background fill/.style={fill=#1},
  background fill/.default={white},
  background default fill/.style={
    background fill/.default={#1},
  },
  fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
  background draw/.style={draw=#1},
  background draw/.default={white},
  background default draw/.style={
    background draw/.default={#1},
  },
  draw on/.style={alt=#1{}{background draw}}
}

\tikzset{
  background filldraw/.style args={#1 filled by #2}{draw=#1, fill=#2},
  background filldraw/.default=white filled by white,
  background default filldraw/.style={
    background filldraw/.default={#1},
  },
  filldraw on/.style={alt=#1{}{background filldraw}},
}

\tikzset{
  background aspect/.style={#1},
  background aspect/.default={white},
  background default aspect/.style={
    background aspect/.default={#1},
  },
  aspect on/.style={alt=#1{}{background aspect}},
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={top color=white, bottom color=white},
  background default shade/.style={
    background shade/.default={#1},
  },
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background shadedraw/.style 2 args={draw=#1, #2},
  background shadedraw/.default={white}{top color=white, bottom color=white},
  background default shadedraw/.style={
    background shadedraw/.default={#1},
  },
  shadedraw on/.style={alt=#1{}{background shadedraw}},
}
%    \end{macrocode}
% At this point, some comments are needed on the subsequent option \texttt{double disabled}. For the best of my knowledge, this is option is not implemented in PGF 2.10 either in PGF 3.0.0, but it is absolutely relevant to the scope of this library. Suppose you wish to alter a double path by removing in some moments its double property: without the following option, it would not be possible (at least without redrawing the path).
%    \begin{macrocode}
% option for disabling double when not needed in 
% subsequent overlays
\tikzoption{double disabled}[0pt]{%
  \pgfmathsetlength{\pgf@x}{#1}%
  \edef\tikz@double@setup{%
    \pgf@x=\the\pgf@x%
    \pgflinewidth=\pgf@x%
    \noexpand\pgfsetlinewidth{\pgflinewidth}%
    \noexpand\pgfsetinnerlinewidth{\the\pgf@x}%
  }%
\tikzset{double}}
%    \end{macrocode}
%
% \iffalse
%</tikzlibrary>
% \fi
% 
% \section{Example}
% It follows a complete example which exploits all the defined styles. The first frame mainly reports showcases of border, filling and shading properties modifications. The second frame shows examples of modifications for the remaining properties, including text color and path aspect.
%
% \iffalse
%<*example>
% \fi
%    \begin{macrocode}
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,
  shapes.geometric,
  shadows
}
% loading new library
\usetikzlibrary{overlay-beamer-styles}

\definecolor{processblue}{cmyk}{0.96,0,0,0}

\begin{document}
\begin{frame}{Styles for draw, fill and shading modifications}
\begin{columns}[T]
\begin{column}{0.2\textwidth}
\centering
Fill draw\\[2ex]
\tikz[baseline=(A.base)]{%
\node[background fill=red!50,%
      fill on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {ABCD};
}

\tikz[baseline=(A.base)]{%
\node[background fill=blue!50,%
      fill on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {EFGH};
}

\tikz[baseline=(A.base)]{%
\node[background draw=red,%
      draw on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {IJKL};
}

\tikz[baseline=(A.base)]{%
\node[background draw=blue,%
      draw on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {MNOP};
}

\tikz[baseline=(A.base)]{%
\node[background filldraw=red filled by blue!10,%
      filldraw on=<2>,anchor=base,%
      rounded corners,%
      ] (A) {QRST};
}
\end{column}
\begin{column}{0.2\textwidth}
\centering
Shadings\\[2ex]
\tikz[baseline=(A.base)]{%
\node[background shade={top color=red!50, bottom color=white},%
      shade on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {ABCD};
}

\tikz[baseline=(A.base)]{%
\node[background shade={inner color=red!50, outer color=white},%
      shade on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {EFGH};
}

\tikz[baseline=(A.base)]{
\node[background shade={left color=orange!50, right color=white},%
      shade on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {IJKL};
}

\tikz[baseline=(A.base)]{
\node[background shadedraw={blue}{top color=white, bottom color=cyan!30},%
      shadedraw on=<{1,3}>,%
      anchor=base,%
      rounded corners,%
      ] (A) {MNOP};
}

\tikz[baseline=(A.base)]{
\node[background shadedraw={green!50!black}{inner color=white,%
      outer color=green!30},%
      shadedraw on=<2>,%
      anchor=base,%
      rounded corners,%
      ] (A) {QRST};
}
\end{column}
\begin{column}{0.55\textwidth}
\centering
Node application\\[2ex]
\begin{tikzpicture}[node distance=0.5cm]
%    \end{macrocode}
% Of course, it is always possible to group in high-level styles the styles provided by \aobstikz.
%    \begin{macrocode}
\tikzset{visibility 1/.style={
      background draw=red, draw on=<{1,4}>,
      background shade={top color=white,
      bottom color=red!30},
      shade on=<{2,3}>,
      }
}
\tikzset{visibility 2/.style={
      background shadedraw={green!50!black}{inner color=white,
      outer color=green!30},
      shadedraw on=<{2,3}>,
      }
}
\tikzset{visibility 3/.style={
      background draw=orange,
      draw on=<1->,
      background fill={orange!30},
      fill on=<{2,3}>,
    }
}
%    \end{macrocode}
% The following high-level style shows that the new styles can be combined to obtained more fine results. Specifically, rather than using a \textit{shadedraw} modification, the \texttt{visibility 4} style exploits separately \textit{shade} and \textit{draw} modifications to having them visible in different overlays.
%    \begin{macrocode}
\tikzset{visibility 4/.style={
      background draw=purple,
      draw on=<2->,
      background shade={left color=purple!30,
      right color=cyan!30},
      shade on=<{3,4}>,
    }
}
\node[trapezium,
      visibility 1] (A) {Text};
\node[trapezium,
      visibility 2,
      below= of A] (B) {Text};
\node[trapezium,
      visibility 3,
      below= of B] (C) {Text};
\node[trapezium,
      visibility 4,
      below= of C] (D) {Text};
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}

\begin{frame}{Styles for path aspect and text color modifications}
\centering
\begin{tikzpicture}[node distance=3cm and 2cm,
      semithick ,
      state/.style={circle,
            top color=white,
            bottom color=processblue!20,
            draw, processblue,
            text=blue,
            minimum width=1cm},
      background default shade={top color=white,
            bottom color=processblue!20},
      background default draw={processblue,
            semithick}]
%    \end{macrocode}
% Shadows can be managed with the help of the style \texttt{visible on}: it follows an example with a \textit{circular drop shadow}.
%    \begin{macrocode}
\node[state,
      background draw={blue!80,
            line width=1mm},
      draw on=<2>,
      circular drop shadow={visible on=<2>},
      visible on=<{1,2}>% NOT visible in 3 
     ] (C) {$1$};
\node[state,
      background draw={orange},
      draw on=<{1,3}>,
      background default aspect={semithick,
            double disabled},
      background aspect={double},
      aspect on=<{1,3}>,
      background shade={top color=white,
            bottom color=orange!30},
      shade on=<{1,3}>,
      above left= of  C] (A) {$0$};

\node[state,
      background text=violet,
      background default text=red,
      text on=<2>,
      above right= of C] (B) {$2$};

\draw (A)-- (B) (C)-- (A);

\draw[background default aspect={solid,semithick},
      background aspect={dashdotted,
            very thick},
      aspect on=<{2,3}>,
      background default draw={black},
      background draw={red},
      draw on=<3>](B)-- (C);
\end{tikzpicture}
\end{frame}
\end{document}
%    \end{macrocode}
% \iffalse
%</example>
% \fi
%
% 
%\Finale
