[Tex/LaTex] Latex beamer block shadow fades to white and not to the background color

beamer

I modified the background color using \setbeamercolor{background canvas}{bg=blue!25}. However, the shadow of the blocks fade from black to white and not to the background color (resulting in a tiny white stripe around the shadow before the background color takes over), see code below.

I found the following fix
How to add a transparent shadow to a block in beamer?

(there the white line around the shadow can also be seen clearly)

However, the modified version of beamerbaseboxes.sty seems to be outdated, since it changes the appearance of the whole presentation, not only the shadows. Since I do not want transparent shadows but merely shadows that fade into the background color, I would like to ask how to achieve this without hacking the beamerbaseboxes.sty file.

\documentclass{beamer}
\usetheme{Madrid}

\setbeamercolor{background canvas}{bg=blue!25}

\begin{document}

\frame{
  \begin{block}{test block} 
  block block
 \end{block}

}

\end{document}

Best Answer

The following code will give the expected output:

\documentclass{beamer}

\usetheme{Madrid}
\usepackage[T1]{fontenc}
\setbeamercolor{background canvas}{bg=blue!25}

\makeatletter
\pgfdeclareverticalshading[black,bg]{bmb@shadow}{200cm}{%
  color(0bp)=(blue!25); color(4bp)=(black!50!bg); color(8bp)=(black!50!bg)}
\pgfdeclareradialshading[black,bg]{bmb@shadowball}{\pgfpointorigin}{%
  color(0bp)=(black!50!bg); color(4bp)=(blue!25)}
\pgfdeclareradialshading[black,bg]{bmb@shadowballlarge}{\pgfpointorigin}{%
  color(0bp)=(black!50!bg); color(4bp)=(black!50!bg); color(8bp)=(blue!25)}
  %
   \makeatother

\begin{document}

\frame{\frametitle{l}
  \begin{block}{in a block} 
  default font
 \end{block}
}

\end{document}

Please note: this is of course a hack to beamerbasebox since the original definitions are overwritten. I do not know if there could possibly be any side effects. (Those shadows could be used anywhere else...). And of course i have no idea why it does not choose the background color automatically.

enter image description here

Related Question