如何使用 TikZ 应用剪贴蒙版

如何使用 TikZ 应用剪贴蒙版

无需重写代码,我希望圆圈重叠的部分是透明的,因此它看起来是白色的(或隐藏在圆圈后面的任何颜色)。

平面设计师可能会将此称为剪贴蒙版阿尔法合成等等。
这是一个布尔运算:A XOR B。

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[node distance=3.50em, auto]

%%% define shapes %%%
\tikzstyle{bluecircle} = [draw, circle,
                          fill=blue!20,
                          line width=0.00em, 
                          minimum height=5.00em,
                          text centered]

\tikzstyle{emptycircle} = [draw, circle,
                           fill=none,
                           line width=0.10em,
                           minimum height=5.00em,
                           text centered]

\tikzstyle{emptysquare} = [draw, rectangle,
                           fill=none,
                           line width=0.10em,
                           minimum height=6.00em,
                           text width = 9.00em,
                           text centered]

%%% circle fill %%%   
\node[bluecircle]             (A) {};
\node[bluecircle, right of=A] (B) {};

%%% circle edge %%%    
\node[emptycircle]             (A2) {$A$};
\node[emptycircle, right of=A] (B2) {$B$};

%%% square edge %%%    
\node[emptysquare, xshift=1.75em] (U) {};

\end{tikzpicture}    
\end{document}

答案1

使用clip命令可以得到以下结果。

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[node distance=3.50em, auto]

%%% define shapes %%%
\tikzstyle{bluecircle} = [draw, circle,
                          fill=blue!20,
                          line width=0.00em, 
                          minimum height=5.00em,
                          text centered]

\tikzstyle{emptycircle} = [draw, circle,
                           fill=none,
                           line width=0.10em,
                           minimum height=5.00em,
                           text centered]

\tikzstyle{emptysquare} = [draw, rectangle,
                           fill=none,
                           line width=0.10em,
                           minimum height=6.00em,
                           text width = 9.00em,
                           text centered]

%%% circle fill %%%   
\node[bluecircle]             (A) {};
\node[bluecircle, right of=A] (B) {};

%%% circle edge %%%    
%\node[emptycircle]             (A2) {};
%\node[emptycircle, right of=A] (B2) {$B$};

%%% square edge %%%    
\node[emptysquare, xshift=1.75em] (U) {};

\begin{scope}
        \clip (A.center) circle [radius=2.5em];
        \fill[fill=white] (B.center) circle [radius=2.5em];
    \end{scope}
%%% circle edge %%%     
\node[emptycircle]             (A2) {$A$};
\node[emptycircle, right of=A] (B2) {$B$};

\end{tikzpicture}    
\end{document}

在此处输入图片描述

相关内容