4

I tried to implement the suggestions of this answer (Paul Gaborit's invclip) to make a "spotlight" effect (to be used with beamer). It works perfectly with simple shapes, but things get tricky when using decorations, since these are applied to the big rectangle as well (the page in my case).

\path[invclip, decorate, decoration=...] <path>;

This also happens with rounded corners, but I was able to solve that by scoping the relevant path:

\path[invclip] {[rounded corners] <path>};

But this does not seem to work with decorations.

I've tried to disable decorations for the big rectangle (decorate=false) to no effect.

Any suggestions?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, decorations, decorations.pathmorphing}

\begin{document}

\tikzset{
    invclip/.style={
        clip, insert path={{(current page.north east) rectangle (current page.south west)}}},
    invclip2/.style={
        clip, insert path={{[decorate=false] (current page.north east) rectangle (current page.south west)}}
    }
}

\begin{tikzpicture}[remember picture, overlay]
\begin{scope}
    \begin{pgfinterruptboundingbox}
        \path [invclip, decorate, decoration={zigzag}] (0,0) circle [radius=1cm];
        \path [invclip] {[decorate, decoration={zigzag}] (3,0) circle [radius=1cm]};
    \end{pgfinterruptboundingbox}
\fill[fill opacity=.5, black, even odd rule] (current page.south east) rectangle (current page.north west);
\end{scope}
\end{tikzpicture}

\pagebreak

\begin{tikzpicture}[remember picture, overlay]
\begin{scope}
    \begin{pgfinterruptboundingbox}
        \path [invclip2, decorate, decoration={zigzag}] (0,3) circle [radius=1cm];
        \path [invclip2] {[decorate, decoration={zigzag}] (3,3) circle [radius=1cm]};
    \end{pgfinterruptboundingbox}
\fill[fill opacity=.5, black, even odd rule] (current page.south east) rectangle (current page.north west);
\end{scope}
\end{tikzpicture}

\end{document}
4

You are almost there with the second path of each example. You can select a subpath to be decorated hence you need to supply the path as a subpath with decoration only applied to that subpath

\path [invclip] decorate[decoration={zigzag}]{(0,0) circle [radius=1cm]};
  • One extra question: this works fine for a decoration like zigzag, but straight zigzag (manual 48.3.1) fails with ! Undefined control sequence. <argument> \pgf@decorate@decorationlist . Any clue? – Christoph Frings May 25 '17 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.