5

I am a bit confused about the behavior of TikZ fadings. Here is my MWE

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}


\newcommand{\FadingQuarterArrowOne}[2][]{
\begin{scope}[transform canvas={rotate=#2},#1]
\shade [gray,path fading=south] (-40:1) -- (-40:1.2) arc (-40:40:1.2 and 1.2) --
(40:1.2) --(40:1.3) --
(45:1.1) -- (40:0.9) -- (40:1) arc  (40:-40:1 and 1); 
\end{scope}
}           

\newcommand{\FadingQuarterArrowTwo}[2][]{
\begin{scope}[transform canvas={rotate=#2},#1]
\shade [gray,path fading=north] (40:1) -- (40:1.2) arc (40:-40:1.2 and 1.2) --
(-40:1.2) --(-40:1.3) --
(-45:1.1) -- (-40:0.9) -- (-40:1) arc   (-40:40:1 and 1); 
\end{scope}
}           

\begin{document}


\tikz[baseline=(current bounding box.south)]{\FadingQuarterArrowOne[scale=2]{0}}
\hspace*{3cm}
\tikz[baseline=(current bounding box.south)]{\FadingQuarterArrowTwo[scale=2]{0}}

\end{document}

enter image description here

The left arrow is as I expect it to be, it fades away towards the "southern" direction. However, the second arrow, which is just the reverse of the first one, fades away towards the outer regions. I'd like to understand why that happens, and how to fix this.

1 Answer 1

5

In the left case, the shading is from top (gray) to bottom (white). The fading to south follows this direction and increases the effect.

In the right case, the shading angle needs to be fixed by shading angle=180 to get a shading from bottom (gray) to top (white). Then, the effect is increased by fading to north.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}

\newcommand{\FadingQuarterArrowOne}[2][]{%
  \begin{scope}[transform canvas={rotate=#2},#1]
    \shade [gray,path fading=south]
      (-40:1) -- (-40:1.2) arc (-40:40:1.2 and 1.2) --
      (40:1.2) -- (40:1.3) --
      (45:1.1) -- (40:0.9) -- (40:1) arc (40:-40:1 and 1);
  \end{scope}%
}

\newcommand{\FadingQuarterArrowTwo}[2][]{%
  \begin{scope}[transform canvas={rotate=#2},#1]
    \shade [gray, shading angle=180, path fading=north]
      (40:1) -- (40:1.2) arc (40:-40:1.2 and 1.2) --
      (-40:1.2) -- (-40:1.3) --
      (-45:1.1) -- (-40:0.9) -- (-40:1) arc (-40:40:1 and 1);
  \end{scope}%
}

\begin{document}

\tikz[baseline=(current bounding box.south)]{\FadingQuarterArrowOne[scale=2]{0}}
\hspace*{3cm}
\tikz[baseline=(current bounding box.south)]{\FadingQuarterArrowTwo[scale=2]{0}}

\end{document}

Result

This works with Acrobat Reader, xpdf, Ghostscript, and Firefox. But evince 2.32 shows the wrong result, and Google Chrome shows an empty page.

7
  • Thanks a lot! Then my interpretation of path fading= was incorrect. BTW, it also shows correctly on preview, a tool on Mac OS.
    – user121799
    Jan 7, 2018 at 3:42
  • How do you get ghostscript to display anything?
    – cfr
    Jan 7, 2018 at 4:16
  • @cfr Ghostscript was used to generate the image, version is 9.22. Jan 7, 2018 at 4:31
  • I guess I just don't get it. Probably just being very dumb.
    – cfr
    Jan 7, 2018 at 5:06
  • 1
    A recent version of evince (3.26) shows the correct result... Jan 7, 2018 at 8:30

You must log in to answer this question.