[Patch] Real transparency for box shadows

View: New views
7 Messages — Rating Filter:   Alert me  

Parent Message unknown [Patch] Real transparency for box shadows

by Андрей Парамонов :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

I've implemented "real" transparency for Beamer box shadows. It allows
to position boxes on top of existing content, with the pleasing visual
effect of fuzzy shadow.

The implementation is based on fadings, that is transparency
gradients. That's somewhat advanced feature which may or may not work
depending on output format and viewer. For example, pdf in xpdf and
acroread work, while pdf in evince fails (I'm going to fill a bug
report).

Hope you'll find my code useful,
Andrey Paramonov

[beamerbaseboxes.sty]

% Copyright 2007 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/licenses/LICENSE for more details.

\RequirePackage{keyval}

\def\beamerboxesdeclarecolorscheme#1#2#3{% scheme name, upper color, lower color
  \setbeamercolor{@scheme upper #1}{fg=white,bg=#2}
  \setbeamercolor{@scheme lower #1}{bg=#3}
}

\define@key{beamerboxes}{scheme}{\def\bmb@upper{@scheme upper #1}\def\bmb@lower{@scheme lower #1}}
\define@key{beamerboxes}{upper}{\def\bmb@upper{#1}}
\define@key{beamerboxes}{lower}{\def\bmb@lower{#1}}
\define@key{beamerboxes}{width}{\edef\bmb@width{#1}}
\define@key{beamerboxes}{shadow}[true]{\csname bmb@shadow#1\endcsname}

\newif\ifbmb@shadow
\newbox\bmb@box
\newbox\bmb@colorbox
\newdimen\bmb@boxwidth
\newdimen\bmb@boxheight
\newdimen\bmb@prevheight
\newdimen\bmb@temp
\newdimen\bmb@dima
\newdimen\bmb@dimb

\newcommand\beamerboxesrounded[2][]{%
  \global\let\beamer@firstlineitemizeunskip=\relax%
  \vbox\bgroup%
  \setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false}%
  \setkeys{beamerboxes}{#1}%
  {%
    \usebeamercolor{\bmb@lower}%
    \globalcolorstrue%
    \colorlet{lower.bg}{bg}%
  }%
  {%
    \usebeamercolor{\bmb@upper}%
    \globalcolorstrue%
    \colorlet{upper.bg}{bg}%
  }%
  %
  % Typeset head
  %
  \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%
  \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
  \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
  \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}
      \pgfpathqcurveto{-4bp}{1.2bp}{-2.2bp}{3bp}{0bp}{3bp}
      \pgfpathlineto{\pgfpoint{\bmb@temp}{3bp}}
      \pgfpathcurveto%
      {\pgfpoint{\bmb@dima}{3bp}}%
      {\pgfpoint{\bmb@dimb}{1.2bp}}%
      {\pgfpoint{\bmb@dimb}{-1bp}}%
      \bmb@dima=-\ht\bmb@box%
      \advance\bmb@dima by-2pt%
      \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%
      \advance\bmb@dima by8bp%
      \pgfpathrectangle{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
      \pgfusepath{clip}
      {\pgftransformshift{\pgfpoint{-4bp}{0bp}}\pgftext[left,base]{\pgfuseshading{bmb@transition}}}%
    \end{pgfpicture}%
  }%
  \nointerlineskip%
  \vskip-0.5pt%
  \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%
  \bmb@temp=\dp\bmb@box%
  \advance\bmb@temp by.5pt%
  \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
  \dp\bmb@box=0pt%
  \bmb@boxwidth=\bmb@width%
  \bmb@boxheight=\ht\bmb@box%
  \advance\bmb@boxheight by4bp%
  \advance\bmb@boxheight by\bmb@prevheight%
  \bmb@temp=\bmb@width%
  \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
  \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
  \hbox{%
    \begin{pgfpicture}{0bp}{0bp}{0bp}{0bp}
      \ifbmb@shadow%
      \begin{pgfscope}
        \def\bmb@origin{\pgfpoint{4bp}{-3bp}}%
        \pgfpathrectangle{\bmb@origin}{\pgfpoint{-4bp}{-4bp}}%
        \pgfsetfading{bmb@shadowballmask}{\pgftransformshift{\bmb@origin}}%
        \pgfusepath{fill}%
      \end{pgfscope}
      \begin{pgfscope}
        \def\bmb@origin{\pgfpoint{4bp}{-3bp}}%
        \pgfpathrectangle{\bmb@origin}{\pgfpoint{\bmb@boxwidth-4bp}{-4bp}}%
        \pgfsetfading{bmb@shadowvertmask}{\pgftransformshift{\bmb@origin}}%
        \pgfusepath{fill}%
      \end{pgfscope}
      \begin{pgfscope}
        \def\bmb@origin{\pgfpoint{\bmb@boxwidth}{1bp}}%
        \pgfpathrectangle{\bmb@origin}{\pgfpoint{8bp}{-8bp}}%
        \pgfsetfading{bmb@shadowballlargemask}{\pgftransformshift{\bmb@origin}}%
        \pgfusepath{fill}%
      \end{pgfscope}
      \begin{pgfscope}
        \def\bmb@origin{\pgfpoint{\bmb@boxwidth+4bp}{\bmb@boxheight-5bp}}%
        \pgfpathrectangle{\bmb@origin}{\pgfpoint{4bp}{-\bmb@boxheight+6bp}}%
        \pgfsetfading{bmb@shadowhorzmask}{\pgftransformshift{\bmb@origin}}%
        \pgfusepath{fill}%
      \end{pgfscope}
      \begin{pgfscope}
        \def\bmb@origin{\pgfpoint{\bmb@boxwidth+4bp}{\bmb@boxheight-5bp}}
        \pgfpathrectangle{\bmb@origin}{\pgfpoint{4bp}{4bp}}%
        \pgfsetfading{bmb@shadowballmask}{\pgftransformshift{\bmb@origin}}%
        \pgfusepath{fill}%
      \end{pgfscope}
      \fi%
      \unhbox\bmb@colorbox%
      \pgfpathqmoveto{-4bp}{1bp}
      \pgfpathqcurveto{-4bp}{-1.2bp}{-2.2bp}{-3bp}{0bp}{-3bp}
      \pgfpathlineto{\pgfpoint{\the\bmb@temp}{-3bp}}
      \pgfpathcurveto%
      {\pgfpoint{\the\bmb@dima}{-3bp}}%
      {\pgfpoint{\the\bmb@dimb}{-1.2bp}}%
      {\pgfpoint{\the\bmb@dimb}{1bp}}%
      {
        \bmb@dima=\ht\bmb@box%
        \pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
        \pgfusepath{fill}
      }
    \end{pgfpicture}%
    \box\bmb@box%
  }%
  \ifbmb@shadow%
    \vskip4bp minus 2bp%
  \else%
    \vskip2bp%
  \fi%
  \egroup% of \vbox\bgroup
}

%
% Shadings
%

% Shadows
\pgfdeclareradialshading{bmb@shadowball}{\pgfpointorigin}%
{%
  color(0bp)=(pgftransparent!50);
  color(4bp)=(pgftransparent!100)
}
\pgfdeclareradialshading{bmb@shadowballlarge}{\pgfpointorigin}%
{%
  color(0bp)=(pgftransparent!0);
  color(8bp)=(pgftransparent!100)
}
\pgfdeclarehorizontalshading{bmb@shadowhorz}{200cm}%
{%
  color(0bp)=(pgftransparent!0);
  color(8bp)=(pgftransparent!100)
}
\pgfdeclareverticalshading{bmb@shadowvert}{200cm}%
{%
  color(0bp)=(pgftransparent!100);
  color(8bp)=(pgftransparent!0)
}

% Transition line
\pgfdeclareverticalshading[lower.bg,upper.bg]{bmb@transition}{200cm}%
{%
  color(0pt)=(lower.bg);
  color(2pt)=(lower.bg);
  color(4pt)=(upper.bg)
}

%
% Fadings
%
\pgfdeclarefading{bmb@shadowballmask}{\pgfuseshading{bmb@shadowball}}
\pgfdeclarefading{bmb@shadowballlargemask}{\pgfuseshading{bmb@shadowballlarge}}
\pgfdeclarefading{bmb@shadowhorzmask}{\pgfuseshading{bmb@shadowhorz}}
\pgfdeclarefading{bmb@shadowvertmask}{\pgfuseshading{bmb@shadowvert}}



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

beamerbaseboxes-test.tex (680 bytes) Download Attachment

Re: [Patch] Real transparency for box shadows

by Denis Bitouzé :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le vendredi 18/09/09 à 11h02,
Андрей Парамонов <cmr.pent@...> a écrit :

> Hope you'll find my code useful,

It is, indeed: thanks a lot!

Maybe you should send it to Till in order your implementation is nicely
integrated to the official beamer class or, at least, make it available
as an independent package.

Cheers,
--
Denis



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: [Patch] Real transparency for box shadows

by Андрей Парамонов :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/9/18 Denis Bitouzé <dbitouze@...>:
> Maybe you should send it to Till in order your implementation is nicely
> integrated to the official beamer class or, at least, make it available
> as an independent package.

Till says he reads this list. Hope he spots my message ;-)

By the way, I've noticed that some Beamer visual elements could look
nicer. For example, itemize balls are actually polygons, not balls.
However, it seems that "real" balls implementation would not be any
harder, considering pgf great power.

What is the rationale behind it? Is it compatibility, speed or something else?

Andrey

P.S: The display of transparency gradients is fixed in recent versions
of libpoppler.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: [Patch] Real transparency for box shadows

by Bugzilla from cedric.laczny@gmx.de :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday, 18. September 2009 09:02:41 Андрей Парамонов wrote:
> Hello!
>

Hi,

> I've implemented "real" transparency for Beamer box shadows. It allows
> to position boxes on top of existing content, with the pleasing visual
> effect of fuzzy shadow.
>

Looks great!
 
> The implementation is based on fadings, that is transparency
> gradients. That's somewhat advanced feature which may or may not work
> depending on output format and viewer. For example, pdf in xpdf and
> acroread work, while pdf in evince fails (I'm going to fill a bug
> report).
>

It also works for PDF in Okular (PDF-viewer in KDE-4.x)

> Hope you'll find my code useful,

Oh yes, this gives a nice look to the boxes.

Could you perhaps provide a sty-file that one can easily integrate via
/usepackage? Because, as far as I understand it now, it enhances the standard
beamerbaseboxes.sty. However, I would find it useful to include this
functionality separately, like in a new environment for example.

> Andrey Paramonov
>

Best,

Cedric Laczny

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: [Patch] Real transparency for box shadows

by Андрей Парамонов :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/9/18 Cedric Laczny <cedric.laczny@...>:
> Could you perhaps provide a sty-file that one can easily integrate via
> /usepackage?

Yes, it's a good idea. However, I'm not quite sure how to implement
it. Maybe I should \renewcommand, so the new implementation replaces
the default one on \usepackage? Hints appreciated.

> Because, as far as I understand it now, it enhances the standard
> beamerbaseboxes.sty.

Yes.

> However, I would find it useful to include this
> functionality separately, like in a new environment for example.
>

That's problematic, because many useful Beamer environments (like
theorem, example) make use of beamerboxesrounded.

Thanks for your feedback,
Andrey

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Parent Message unknown Re: [Patch] Real transparency for box shadows

by Андрей Парамонов :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/9/18 Bryan W. Lepore <Bryan.Lepore@...>:
> w/ standard TexLive 2007, i got  :
>
> ! Package xcolor Error: Undefined color `pgftransparent'
>
> .... i read some xcolor docs, didn't get far - should i just use either new
> TexLive or new xcolor?
>

I use Debian GNU/Linux Testing, and pgftransparent is defined in

/usr/share/texmf/tex/generic/pgf/basiclayer/pgfcoretransparency.code.tex

You should probably upgrade your PGF package (I have version 2.00-1 installed).

I think I now understand why some things in Beamer were not
implemented via fadings. Looks like PGF simply wasn't able to do
fadings back in the day.

Andrey

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: [Patch] Real transparency for box shadows

by Victor Ivrii :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/9/18 Андрей Парамонов <cmr.pent@...>:

> Hello!
>
> I've implemented "real" transparency for Beamer box shadows. It allows
> to position boxes on top of existing content, with the pleasing visual
> effect of fuzzy shadow.
>
> The implementation is based on fadings, that is transparency
> gradients. That's somewhat advanced feature which may or may not work
> depending on output format and viewer. For example, pdf in xpdf and
> acroread work, while pdf in evince fails (I'm going to fill a bug
> report).
>
> Hope you'll find my code useful,
> Andrey Paramonov


        beamerbaseboxes.sty


here seems to be smaller than one in TL 2008 and TL 2007 but those are
not producing transparency

Victor


--
========================
Victor Ivrii, Professor, Department of Mathematics, University of Toronto
http://www.math.toronto.edu/ivrii

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users