TikZ: how prevent darker fill in overlapping regions

filltikz-pgf

In this TikZ picture, how do I prevent the overlapping regions from becoming darker than the rest? I want the overlap to be the same uniform color as the rest of the regions.

\documentclass[tikz,border=0pt]{standalone}

\begin{document}

\begin{tikzpicture}[scale=0.5]]% Union of two overlapping irregular regions
  % First region
  \fill[red, opacity=0.3] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  \draw[thick] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  \node at (-.5,0.75) {$A$};
  
  % Second region
  \fill[red, opacity=0.3] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)};
  \draw[thick] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)}; 

\node at (3,0.5) {$B$};

 \node at (0.5, -3) {$A \cup B$};
\end{tikzpicture}

\end{document}

union

Best Answer

You could use a transparency group:

\documentclass[tikz,border=0pt]{standalone}

\begin{document}

\begin{tikzpicture}[scale=0.5]% Union of two overlapping irregular regions
  % First region
  \begin{scope}[transparency group,opacity=0.3]
  \fill[red] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  % Second region
  \fill[red] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)};
  \end{scope}
    \draw[thick] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)}; 
  \draw[thick] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  \node at (-.5,0.75) {$A$};
\node at (3,0.5) {$B$};

 \node at (0.5, -3) {$A \cup B$};
\end{tikzpicture}

\end{document}

enter image description here

... or just not use opacity:

\documentclass[tikz,border=0pt]{standalone}

\begin{document}

\begin{tikzpicture}[scale=0.5]% Union of two overlapping irregular regions
  \fill[red!30] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  % Second region
  \fill[red!30] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)};
  \draw[thick] plot [smooth cycle,tension=1] coordinates {(1,1.5) (3,2) (4,0) (3,-1) (2,-2) (1,-0.5)}; 
  \draw[thick] plot [smooth cycle,tension=1] coordinates {(-1,1) (1,2) (2,0) (1,-1.5) (-1,-2) (-2,-0.5)};
  \node at (-.5,0.75) {$A$};
  \node at (3,0.5) {$B$};
  \node at (0.5, -3) {$A \cup B$};
\end{tikzpicture}

\end{document}
Related Question