tikz add tag
samcarter
I stumbled over this while working on transparent shadows for the [smoothbars outer beamer theme](https://github.com/josephwright/beamer/issues/717) and am wondering why does the fading in the following MWE only stretch over half the space? If I change the scaling factor to `2` it will exactly fill it, but why is this necessary?

```
\documentclass{standalone}

\usepackage{tikz}

\pgfdeclareverticalshading{myshade}{3cm}{%
  color(0ex)=(pgftransparent!100);%
  color(1ex)=(pgftransparent!0)
}
\pgfdeclarefading{mymask}{\pgfuseshading{myshade}}

\begin{document}

\fbox{\begin{pgfpicture}
  \pgfsetfillcolor{red}%
  \pgfpathrectangle{\pgfpoint{0pt}{-1ex}}{\pgfpoint{3cm}{1.2ex}}%
  \pgfsetfading{mymask}{\pgftransformscale{1}}%
  \pgfusepath{fill}%
\end{pgfpicture}}

\end{document}
```

![document2.png](/image?hash=d2abba614ede2640a5bec21f44e933722c46267de3e5adac0354b3d25641e2a1)
Top Answer
samcarter
I think the behaviour is explained in this comment by @muzimuzhi

> Since `fit fading=false` is set, the fading area is not shifted nor scaled to fit the current path. It is just centered at `(0,0)`. Manually adding the needed shifting `fading transform={xshift=-.5,yshift=.5}` seems to fix the problem.
>
> But I don't understand the behavior when `fit fading=false` is removed.

(form  https://github.com/pgf-tikz/pgf/issues/978#issuecomment-757384587 )

So in reality my fading is scaled perfectly, I just choose my coordinates in such an unfortunate way that half the shape was cut off. Modifying my code to show a larger section shows that the shading is indeed perfectly positioned at (0,0) and does has the correct size of 3 cm times 1 ex:

```
\documentclass{standalone}

\usepackage{tikz}

\pgfdeclareverticalshading{myshade}{3cm}{%
  color(0bp)=(pgftransparent!100);%
  color(1ex)=(pgftransparent!0)
}
\pgfdeclarefading{mymask}{\pgfuseshading{myshade}}

\begin{document}

\begin{pgfpicture}
  \pgfsetfillcolor{red}%
  \pgfpathrectangle{\pgfpoint{-3cm}{-1ex}}{\pgfpoint{6cm}{2ex}}%
  \pgfsetfading{mymask}{\pgftransformscale{1}}%
  \pgfusepath{fill}%
\end{pgfpicture}

\end{document}
```

![document.png](/image?hash=e0f85cdc3ad35c75c223c9928c3614c8e4813cda39e6aeac089f698295bdde8a)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.