3

Without rewriting the code, I want the part where the circles overlap to be transparent so it appears white (or whatever colour is hiding behind the circles).

Graphic designers might refer to this as a clipping mask, alpha compositing, etc.
It's a boolean operation: A XOR B.

enter image description here

\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}
  • You can use venndiagram package. Please see this link. – A Diyanat Jul 20 '19 at 16:56
  • 1
    If you draw the circles with paths instead of nodes, you can fill the paths according to the even odd rule. Search for that in the manual and I think you’ll find what you’re looking for. – Matthew Leingang Jul 20 '19 at 17:04
  • @MatthewLeingang It has to be nodes. Although the nodes do technically draw paths, and it's the paths that need clipping. Surely it's possible. I can't seem to figure it out though. – voices Jul 20 '19 at 18:07
3

Using clip command, the following result can be obtained.

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

enter image description here

| improve this answer | |

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.