# Can I manipulate the rounded-ness of blocks?

I'm creating a beamertemplate (for beamerposter, actually) and I want to increase the radius of a block. According to the beamer manual (12.3) I can pass the [rounded] option to a block or the beamertemplate blocks in order to make the borders round. But the rounded corners look really small, so I'd like to play around with the radius of the circle that specifies the round corner. How can I do that?

-

The document class beamer internally uses \pgfpathqmoveto, \pgfpathqcurveto and \pgfpathlineto to build the rounded boxes, so you can play with the values used in the original definition (it can be found in the file beamerbaseboxes.sty).

In the code below I show a variation in which I changed the values for the rounded corners for the upper part of the blocks (these changes have to be made in the definition of \beamerboxesrounded, which builds the upper part of the blocks); the original definitions appear commented out and marked with % original at the end of the lines; the modified lines appear right afterwards and are marked with % NEW.

To change the rounded corners for the bottom of the blocks you will have to make similar changes in some lines of \endbeamerboxesrounded (which builds the lower part of the blocks); the lines in which changes will have to be made are marked with % original:change.

\documentclass{beamer}
\usetheme{Warsaw}
\setbeamertemplate{blocks}[rounded]

\makeatletter
\renewcommand\beamerboxesrounded[2][]{%
\global\let\beamer@firstlineitemizeunskip=\relax%
\vbox\bgroup%
\setkeys{beamerboxes}{#1}%
{%
\usebeamercolor{\bmb@lower}%
\globalcolorstrue%
\colorlet{lower.bg}{bg}%
}%
{%
\usebeamercolor{\bmb@upper}%
\globalcolorstrue%
\colorlet{upper.bg}{bg}%
}%
%
%
\vskip4bp
\setbox\bmb@box=\hbox{%
\begin{minipage}[b]{\bmb@width}%
\usebeamercolor[fg]{\bmb@upper}%
#2%
\end{minipage}}%
\ifdim\wd\bmb@box=0pt%
\setbox\bmb@box=\hbox{}%
\ht\bmb@box=1.5pt%
\bmb@prevheight=-4.5pt%
\else%
\wd\bmb@box=\bmb@width%
\bmb@temp=\dp\bmb@box%
\ifdim\bmb@temp<1.5pt%
\bmb@temp=1.5pt%
\fi%
\setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
\dp\bmb@box=0pt%
\bmb@prevheight=\ht\bmb@box%
\fi%
\bmb@temp=\bmb@width%
\hbox{%
\begin{pgfpicture}{0bp}{+-\ht\bmb@box}{0bp}{+-\ht\bmb@box}
\ifdim\wd\bmb@box=0pt%
\color{lower.bg}%
\else%
\color{upper.bg}%
\fi%
%      \pgfpathqmoveto{-4bp}{-1bp}% original
%      \pgfpathqcurveto{-4bp}{1.2bp}{-2.2bp}{3bp}{0bp}{3bp}% original
\pgfpathqmoveto{-4bp}{-6bp}% NEW
\pgfpathqcurveto{-4bp}{-0.8bp}{-1.2bp}{2bp}{5bp}{3bp}% NEW
%      \pgfpathlineto{\pgfpoint{\bmb@temp}{3bp}}% original
\pgfpathlineto{\pgfpoint{\bmb@temp-6pt}{3bp}}% NEW
\pgfpathcurveto%
%       {\pgfpoint{\bmb@dima}{3bp}}% original
%       {\pgfpoint{\bmb@dimb}{1.2bp}}% original
%      {\pgfpoint{\bmb@dimb}{-1bp}}% original
{\pgfpoint{\bmb@dima-2bp}{1bp}}% NEW
{\pgfpoint{\bmb@dimb-2bp}{-1.2bp}}% NEW
{\pgfpoint{\bmb@dimb}{-6bp}}% NEW
\bmb@dima=-\ht\bmb@box%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
\pgfusepath{fill}
\end{pgfpicture}%
\copy\bmb@box%
}%
\nointerlineskip%
\vskip-1pt%
\ifdim\wd\bmb@box=0pt%
\else%
\hbox{%
\begin{pgfpicture}{0pt}{0pt}{\bmb@width}{6pt}
\bmb@dima=\bmb@width%
\pgfpathrectangle{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
\pgfusepath{clip}
\end{pgfpicture}%
}%
\nointerlineskip%
\vskip-0.5pt%
\fi%
\fi%
\setbox\bmb@colorbox=\hbox{{\pgfpicturetrue\pgfsetcolor{lower.bg}}}%
\setbox\bmb@box=\hbox\bgroup\begin{minipage}[b]{\bmb@width}%
\vskip2pt%
\usebeamercolor[fg]{\bmb@lower}%
\colorlet{beamerstructure}{upper.bg}%
\colorlet{structure}{upper.bg}%
%\color{.}%
}

\def\endbeamerboxesrounded{%
\end{minipage}\egroup%
\wd\bmb@box=\bmb@width%
\bmb@temp=\dp\bmb@box%
\setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
\dp\bmb@box=0pt%
\bmb@temp=\wd\bmb@box%
\hbox{%
\begin{pgfpicture}{0bp}{0bp}{0bp}{0bp}
\begin{pgfscope}
{%
\pgfpathrectangle{\pgfpoint{\bmb@temp}{-7bp}}{\pgfpoint{9bp}{9bp}}%
\pgfusepath{clip}
}%
\end{pgfscope}
\begin{pgfscope}
\pgfpathrectangle{\pgfpoint{4bp}{-7bp}}{\pgfpoint{\bmb@temp}{5bp}}
\pgfusepath{clip}
\end{pgfscope}
\begin{pgfscope}
\bmb@dima=\ht\bmb@box%
\pgfpathrectangle{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
\pgfusepath{clip}
\pgfpathrectangle{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
\pgfusepath{clip}
{\pgftransformshift{\pgfpoint{\bmb@temp}{-3bp}}%
\pgftransformrotate{90}%
\end{pgfscope}
\fi%
\unhbox\bmb@colorbox%
\pgfpathqmoveto{-4bp}{1bp}% original:change
\pgfpathqcurveto{-4bp}{-1.2bp}{-2.2bp}{-3bp}{0bp}{-3bp}% original:change
\pgfpathlineto{\pgfpoint{\the\bmb@temp}{-3bp}}% original:change
\pgfpathcurveto%
{\pgfpoint{\the\bmb@dima}{-3bp}}% original:change
{\pgfpoint{\the\bmb@dimb}{-1.2bp}}% original:change
{\pgfpoint{\the\bmb@dimb}{1bp}}% original:change
{
\bmb@dima=\ht\bmb@box%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
\pgfusepath{fill}
}
{
\color{black!50!bg}
\pgfsetlinewidth{0pt}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{-.5bp}}
\bmb@dima=\ht\bmb@box%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\bmb@temp=\bmb@dima
\color{black!31!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\color{black!19!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\color{black!6!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\color{bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
}
\fi
\end{pgfpicture}%
\box\bmb@box%
}%
\vskip4bp minus 2bp%
\else%
\vskip2bp%
\fi%
\egroup% of \vbox\bgroup
}
\makeatother
\begin{document}

\begin{frame}
\begin{exampleblock}{test}
test
\end{exampleblock}
\end{frame}

\end{document}


-
Great answer. Thank you! I suppose there is no way to do this without redefining the entire command, right? –  bitmask Mar 13 '13 at 2:48
@bitmask there's another possibility and it is to patch the commands using, for example, the xpatch package. –  Gonzalo Medina Mar 13 '13 at 12:52