# TikZ semi transparent contiguous shapes with no gaps

Short Question:

The short question can be stated as follows: Is there a way to perfectly align filled (but possibly not drawn) shapes that completely cover contiguous areas?

Consider the MWE:

\documentclass[tikz,crop=true,border=1pt]{standalone}
\definecolor[named]{Back}{cmyk}{0,.3,.94,0}
\definecolor[named]{Front}{cmyk}{0,1.0,.64,.34}
\tikzset{mmaF/.style={fill=Front!#1,draw=Front!#1,
line width=.04pt,opacity=1}}
\tikzset{mmaB/.style={line width=0.01pt,fill=Back!#1,
draw=Back!#1,opacity=.5}}
%
\begin{document}
\begin{tikzpicture}
\begin{scope}[transparency group]
\draw[mmaF=50] (0,0) rectangle ++(2,2);
\draw[mmaB=90] (1,1) rectangle ++(2,2);
\draw[mmaB=90] (-1,-1) rectangle ++(2,2);
\draw[mmaB=90] (-1,1) rectangle ++(2,2);
\draw[mmaF=88] (2,-1) rectangle ++(2,2);
\draw[mmaB=90] (1,-1) rectangle ++(2,2);
\end{scope}
\end{tikzpicture}
\end{document}


Which produces:

If you look closely, there are little doubly drawn lines over the center reddish polygon. If you change draw=Back!#1 for draw=none in style mmaB, then you get little gaps instead of doubly drawn lines.

What makes this question hard is the fact that the order of the polygons is important. I can't simply group the mmaB style polygons into a scope with opacity=.5,transparency group. The reason is explained below, in the background story.

Background Story

Using Mathematica to compute polygons, I can draw things like this:

For the curious, this is just some 10.000+ lines of simple tikz. Mathematica computes the 3D->2D conversion, and gives an ordered collection of plane tikz shapes to be filled with either style mmaF-for front facing polygon- or mmaB-for back facing polygon.

However, I am having trouble when mixing with opacity:

Where you can see the grid lines. Problem: how to remove the grid lines in the semi-transparent part?

-

I'm not sure to understand the question (my english :) ) I use \path instead of \draw.

\documentclass[tikz,crop=true,border=1pt]{standalone}
\definecolor[named]{Back}{cmyk}{0,.3,.94,0}
\definecolor[named]{Front}{cmyk}{0,1.0,.64,.34}
\tikzset{mmaF/.style={fill=Front!#1,opacity=1}}
\tikzset{mmaB/.style={fill=Back!#1, opacity=.5}}
%
\begin{document}
\begin{tikzpicture}
\begin{scope}[transparency group]
\path[mmaF=50] (0,0) rectangle ++(2,2);
\path[mmaB=90] (1,1) rectangle ++(2,2);
\path[mmaB=90] (-1,-1) rectangle ++(2,2);
\path[mmaB=90] (-1,1) rectangle ++(2,2);
\path[mmaF=88] (2,-1) rectangle ++(2,2);
\path[mmaB=90] (1,-1) rectangle ++(2,2);
\end{scope}
\end{tikzpicture}
\end{document}


-
thanks for the answer, but artifacts are still there, whether you use \path or \draw or \filldraw. The four yellowish pieces should neither leave gaps nor overdraw at the "frontier". –  Koji Mar 13 '12 at 11:46
To be more specific: your answer leaves a small, but visible gap between the four yellow pieces. My example in the question above shows overdrawing. I would like to remove both kind of artifacts, if possible. –  Koji Mar 13 '12 at 11:55
@Koji Ok I see the problem with acrobat reader but not with skim or preview on a mac with OS X. –  Alain Matthes Mar 13 '12 at 12:36
I do see the problem with OS X's Preview, though I have to zoom in close enough. –  Koji Mar 13 '12 at 12:40
The problem is important with acrobat with opacity =1 and .5 but seems to disappears with opacity =1 and 1. With skim the problem is important with opacity =1 and 1. If' you draw the borders, the lines are one above the other. Now there are perhaps a problem with the viewers. The problem depends of the zoom. –  Alain Matthes Mar 13 '12 at 13:19