% Copyright 2018 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS{tikzlibraryshadows.code.tex}

\usetikzlibrary{fadings}%


% General options
\tikzset{
  /tikz/shadow scale/.initial=1,
  /tikz/shadow xshift/.initial=0pt,
  /tikz/shadow yshift/.initial=0pt,
}%

% Basic shadow style
\tikzset{
  general shadow/.style={
    preaction={
      #1,
      transform canvas={
        scale around=\pgfkeysvalueof{/tikz/shadow scale}:(current path bounding box.center),
        shift={({\pgfkeysvalueof{/tikz/shadow xshift}},{\pgfkeysvalueof{/tikz/shadow yshift}})}
      },
    }
  },
  every shadow/.style={}
}%



%
% Adds a simple drop shadow to a path
%

\tikzset{
  /tikz/drop shadow/.style={
    general shadow={%
      shadow scale=1,
      shadow xshift=.5ex,
      shadow yshift=-.5ex,
      opacity=.5,
      fill=black!50,
      every shadow,
      #1
    }
  }
}%


%
% Adds a circular drop shadow to a path
%

\tikzset{
  /tikz/circular drop shadow/.style={
    general shadow={%
      shadow scale=1.1,
      shadow xshift=.3ex,
      shadow yshift=-.3ex,
      fill=black!50,
      path fading={circle with fuzzy edge 15 percent},
      every shadow,
      #1
    }
  }
}%



%
% Adds a circular glow to a path
%

\tikzset{
  /tikz/circular glow/.style={
    general shadow={%
      shadow scale=1.25,
      shadow xshift=0pt,
      shadow yshift=0pt,
      fill=black!50,
      path fading={circle with fuzzy edge 15 percent},
      every shadow,
      #1,
    }
  }
}%





%
% Adds a "copy" version of the path behind it.
%

\tikzset{
  /tikz/copy shadow/.style={
    general shadow={%
      /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
      shadow scale=1,
      shadow xshift=.5ex,
      shadow yshift=.5ex,
      fill=\tikz@lib@shadow@fill,
      draw=\tikz@lib@shadow@draw,
      every shadow,
      #1
    }
  }
}%


%
% Adds two "copies" of the path behind it.
%

\tikzset{
  /tikz/double copy shadow/.style={
    general shadow={%
      /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
      shadow scale=1,
      shadow xshift=.5ex,
      shadow yshift=.5ex,
      fill=\tikz@lib@shadow@fill,
      draw=\tikz@lib@shadow@draw,
      #1,
      shadow xshift/.expanded=2*\pgfkeysvalueof{/tikz/shadow xshift},
      shadow yshift/.expanded=2*\pgfkeysvalueof{/tikz/shadow yshift},
    },
    general shadow={%
      /utils/exec={\let\tikz@lib@shadow@fill=\tikz@fillcolor\let\tikz@lib@shadow@draw=\tikz@strokecolor},
      shadow scale=1,
      shadow xshift=.5ex,
      shadow yshift=.5ex,
      fill=\tikz@lib@shadow@fill,
      draw=\tikz@lib@shadow@draw,
      #1,
    },
  }
}%
