# Partial scope transparency in TikZ

When I try to use scope fading, in a scope, it seems to clip the rest of the scope that is not inside the fading rectangle. Interestingly, it seems to clip it at a random place.

Some code and pictures:

\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}

\begin{document}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\begin{tikzpicture}[]
\begin{scope}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) -- (4,3) -- (-2,3);
\draw[wline] (5,0) -- (5,4) -- (-2,4);
\end{scope}
\end{tikzpicture}

\begin{tikzpicture}[]
\begin{scope}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) -- (4,3) -- (-2,3);
\draw[wline] (5,0) -- (5,4) -- (-2,4);
\end{scope}
\end{tikzpicture}
\end{document}


First image:

And this is second image, with fading:

Questions:

Why is it clipping the rest of that?

Why is it clipping there of all places, that isn't even the rectangle-path's boundary?

How do I get what I want to happen?

What I want it to do is actually have a [scope fading=west] rectangle and a [scope fading=south] rectangle on the bottom, and leave everything (read: all parts of things) that lie outside those rectangles fully opaque.

• Welcome to TeX.SX! Please make your code compilable, starting with \documentclass{...} and ending with \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to help you. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Nov 13 '13 at 11:10
• @Jubobs oh, is that necessary if I linked to writelatex at the bottom? – Realz Slaw Nov 13 '13 at 11:17
• @Ignasi oh good point on that. I edited that point out of the question. – Realz Slaw Nov 13 '13 at 11:20
• @RealzSlaw Yes. It's best if you're question is self-contained. – jub0bs Nov 13 '13 at 11:41
• @Jubobs OK I done it. – Realz Slaw Nov 13 '13 at 11:43

Every fading has a prescribed effective region and out of that, it's not rendered. Example;

\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\begin{tikzpicture}[]
\begin{scope}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) |- (-2,3);
\draw[wline] (5,0) |- (-2,4);
\end{scope}
\end{tikzpicture}


This shows that when you rotate the fading you get a little more faded path on the second line.

Let's grab some shading that shows how the effective region is formulated (directly from the manual with minor changes)

\usetikzlibrary{fadings}
{
color(0mm)=(pgftransparent!0);
color(5mm)=(pgftransparent!0);
color(8mm)=(pgftransparent!100);
color(40mm)=(pgftransparent!0)
}

\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\begin{tikzpicture}[]
\begin{scope}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) |- (-2,3);
\draw[wline] (5,0) |- (-2,4);
\end{scope}
\end{tikzpicture}


Notice where 40 mm hits your upper cornered path. So your second question is not entirely correct. The clipping is due to this; if the fading is not defined beyond certain measurements it is not drawn because the fading is stretched or shrunk to your path as a layer.

Long story short your fading defining path should be large enough to cover your to-be-faded paths. If you want to have fixed sized fadings you need fit fading set to be false such that no matter what the fading path is the fading has the same measurements to apply. This is particularly useful if you have custom, fine tuned fadings

\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\begin{tikzpicture}[]
\begin{scope}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) |- (-2,3);
\draw[wline] (5,0) |- (-2,4);
\end{scope}
\end{tikzpicture}


• The issue is, I don't want the fade to start across the entire image; I want it to start on the left 2 cm. – Realz Slaw Nov 13 '13 at 23:34

I can answer part of your question. Regarding to scope fading, in TiKZ manual you can read:

The only difference is, that the effect of the fading will persist after the current path till the end of the scope. Thus, the fading is applied to all subsequent drawings in the current scope, not just to the current path. In this regard, the option works very much like the clip option.

So, it's normal that everything drawn after \path[scope fading=... line appears clipped.

A not so nice solution would be to draw everithing twice, one before fading and another one after that. Probably not what you want but it's the best I can do.

\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}

\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}

right color=transparent!100] (0,0) rectangle (2,5);

\begin{document}\begin{tikzpicture}[]
\draw[wline] (0,0) rectangle (5,5);
\draw[wline] (4,0) -- (4,3) -- (-2,3);
\draw[wline] (5,0) -- (5,4) -- (-2,4);