反向剪切和装饰路径

反向剪切和装饰路径

我尝试实施这个答案(Paul Gaborit 的invclip制作“聚光灯”效果(与 beamer 一起使用)。它与简单的形状配合使用效果很好,但使用装饰时会变得棘手,因为这些装饰也会应用于大矩形(在我的情况下是页面)。

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

圆角也会发生这种情况,但我能够通过确定相关路径的范围来解决这个问题:

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

但这似乎不适用于装饰。

我试图禁用大矩形的装饰(decorate=false),但没有效果。

有什么建议么?

\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}

答案1

您几乎已经了解了每个示例的第二条路径。您可以选择要修饰的子路径,因此您需要将路径作为子路径提供,并且修饰仅应用于该子路径

\path [invclip] decorate[decoration={zigzag}]{(0,0) circle [radius=1cm]};

相关内容