17

In my beamer-document, I'm drawing on a picture as described in this question. I'm trying to hilight particular areas of my picture by making the rest of the picture "fade out", like this:

enter image description here

In my current implementation, I thought I got the desired effect by drawing a rectangular region around the entire picture, then drawing some rectangles inside in the same path, and then filling it with white with opacity 0.9. But it's not working well, because for some reason I don't understand the area outside the rectangles gets "filled", whereas the area outside the circle does not. I guess I'm not supposed to fill paths that are not closed. The fact that I'm trying anyway probably means it's not very stable.

This is my current attempt:

\documentclass[12pt]{beamer}
\usepackage{tikz}
\begin{document}

\begin{frame}

\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=8cm]{BlueMarble}};
     \begin{scope}[x={(image.south east)},y={(image.north west)}]
      \path<2->[fill=white,opacity=.9,draw=black] (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle 
                (0.1,0.5) rectangle (0.3,0.6)
                (0.5,0.4) rectangle (0.6,0.5)
                (0.75, 0.55) circle [radius=0.1];
%                (0.15,0.5) -- (0.15,0.6) -- (0.25,0.6) -- (0.15,0.6) -- cycle;
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
    \end{scope}
\end{tikzpicture}
\end{frame}

\end{document}

What would be a better way of achieving this effect? Ideally, I would like to first make the entire image 90% transparent, and then define some areas that are only 10% transparent. But transparency adds up so it doesn't work that way. Or does it, just differently?

1 Answer 1

8

If I understood you correctly, the problem is that you cannot 'cut out' an arbitrary shape (e.g. the circle) from the transparent overlay. If so, your code is fine, you just need to use an extra option when starting the drawing environment: \begin{tikzpicture}[even odd rule]. That's all. :)

You must log in to answer this question.

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