4

Trying to add color for shadows with shadows.blur library, I have method which consist of modify the code of render blur shadow, here a MWE

\documentclass[margin=2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\makeatletter
\tikzset{render blur shadow/.code=
{\pgfbs@savebb
\pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
\pgfbs@compute@shadow@bbox
\pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
\pgfbs@apply@canvas@transform
\colorlet{pstb@shadow@color}{white!\pgfbs@opacity!violet}%
\pgfdeclarefading{shadowfading}{\pgfbs@paint@fading}%
\pgfsetfillcolor{violet}%
\pgfsetfading{shadowfading}%
{\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
\pgfbs@usebbox{fill}%
\pgfbs@restorebb
},
}
\makeatother

\begin{document}

\begin{tikzpicture}
\node[fill=white, draw=black, blur shadow,font=\Large] {Node};
\end{tikzpicture}

\end{document} 

enter image description here

The original definition of render blur shadow is

render blur shadow/.code=
    {\pgfbs@savebb
    \pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
    \pgfbs@compute@shadow@bbox
    \pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
    \pgfbs@apply@canvas@transform
    \colorlet{pstb@shadow@color}{white!\pgfbs@opacity!black}%
    \pgfdeclarefading{shadowfading}{\pgfbs@paint@fading}%
    \pgfsetfillcolor{black}%
    \pgfsetfading{shadowfading}%
    {\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
    \pgfbs@usebbox{fill}%
    \pgfbs@restorebb
    }

From the above code I just want to change black to violet with a simple manner, I tried to use

render blur shadow/.append code=
{\colorlet{pstb@shadow@color}{white!\pgfbs@opacity!violet}%
\pgfsetfillcolor{violet}%
},

But this does not succeed, any suggestions.

Update

I meant if there is a macro like \patchcmd from etoolbox to change code of render blur shadow like this without rewriting code of render blur command

\patchcmd{render blur command}{black}{violet}{<success>}{<failure>}

Desirable code

\documentclass[margin=2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\patchcmd{render blur command}{black}{violet}{<success>}{<failure>}

\begin{document}

\begin{tikzpicture}
\node[fill=white, draw=black, blur shadow,font=\Large] {Node};
\end{tikzpicture}

\end{document} 
4
  • 1
    So, the problem is that the shadow is ugly? Sorry, I'm not sure I understood. :D
    – Alenanno
    Sep 7, 2016 at 16:52
  • My MWE work perfectly, I want a short method to change render blur shadow without rewrite the entire code
    – Salim Bou
    Sep 7, 2016 at 16:58
  • 1
    Replace black with #1 and use render blur shadow=violet which might need to modify the blur shadow too
    – percusse
    Sep 7, 2016 at 18:02
  • @percusse That gives an error, though (which was unexpected).
    – Alenanno
    Sep 7, 2016 at 18:08

1 Answer 1

4

Why not simply replace black with violet "locally" like this :

\documentclass[tikz,border=7mm]{standalone}
\usetikzlibrary{shadows.blur}
\begin{document}
  \tikzset{
    render blur shadow/.prefix code={
      \colorlet{black}{violet}
    }
  }
  \begin{tikzpicture}
    \node[fill=white, draw=black, blur shadow,font=\Large] {Node};
  \end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .