Balancing opacities between fill and draw
Dirty hack:
If the lines of your particular shape are a tiny bit broader, you don't need to worry about any fill colour as the lines fill the whole shape:
\documentclass{standalone}
\usepackage{tikz}
\tikzstyle{vertex} = [fill, shape=circle, opacity=1, node distance=80pt]
\tikzstyle{hyperedgeline} = [opacity=0.5, cap=round, join=round,line width=60pt]
\tikzstyle{elabel} = [fill, shape=circle, node distance=30pt]
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}
\begin{tikzpicture}
\node[vertex,label=above left:$v_1$] (v1) {};
\node[vertex,right of=v1,label=above right:$v_2$] (v2) {};
\node[vertex,below of=v1,label=below left:$v_3$] (v3) {};
\node[vertex,right of=v3,label=below right:$v_4$] (v4) {};
\begin{pgfonlayer}{background}
\draw[hyperedgeline, color=yellow] (v1.center)--(v2.center)--(v3.center)--cycle;
\draw[hyperedgeline, color=pink, line width=47pt] (v2.center)--(v3.center)--(v4.center)--cycle;
\end{pgfonlayer}
\node[elabel,color=yellow,label=right:$C_1$] (e1) at (-3,0) {};
\node[elabel,below of=e1,color=pink,label=right:$C_2$] (e2) {};
\end{tikzpicture}
\end{document}
I think to proper solution is this. I found it in the manual:
Remove opacity from the "hyperedge" style:
\tikzstyle{hyperedge} = [fill, cap=round, join=round, line width=60pt]
Put every edge in its own transparency group:
\begin{scope}[transparency group, opacity=0.5]
\draw[hyperedge, color=yellow] (v1.center)--(v2.center)--(v3.center)--cycle;
\end{scope}
\begin{scope}[transparency group, opacity=0.5]
\draw[hyperedge, color=pink, line width=45pt] (v2.center)--(v3.center)--(v4.center)--cycle;
\end{scope}
Thank you all for your answers!
Use fill opacity
.
\documentclass{article}
\usepackage{tikz}
\tikzstyle{vertex} = [fill, shape=circle, opacity=1, node distance=80pt]
\tikzstyle{hyperedge} = [opacity=0.5,fill opacity=1, cap=round, join=round, line width=60pt]
\tikzstyle{elabel} = [fill, shape=circle, node distance=30pt]
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}
\begin{tikzpicture}
\node[vertex,label=above left:$v_1$] (v1) {};
\node[vertex,right of=v1,label=above right:$v_2$] (v2) {};
\node[vertex,below of=v1,label=below left:$v_3$] (v3) {};
\node[vertex,right of=v3,label=below right:$v_4$] (v4) {};
\begin{pgfonlayer}{background}
\draw[hyperedge, color=yellow] (v1.center)--(v2.center)--(v3.center)--cycle;
\draw[hyperedge, color=pink, line width=45pt] (v2.center)--(v3.center)--(v4.center)--cycle;
\end{pgfonlayer}
\node[elabel,color=yellow,label=right:$C_1$] (e1) at (-3,0) {};
\node[elabel,below of=e1,color=pink,label=right:$C_2$] (e2) {};
\end{tikzpicture}
\end{document}