2

Quick and hopefully easy question. Is there a way to apply fading both to the filling and to the border of a tikz path?

mwe

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}
  \node at (1, 0.5) {\Large\bfseries fading};
  \draw[ultra thick, fill=purple, path fading=east] (0,0) rectangle (2,1);
\end{tikzpicture}
\end{document}

result

enter image description here

I'd like the black border to fade to alpha in the same way of the filling.

EDIT: Reading the comments it seems something specific to my setup, probably poppler/Evince, with chrome-integrated reader it works fine.

Here's the pdf: https://www.dropbox.com/s/vn402eaw7kil3cj/fade.pdf?dl=0

and the log file: https://www.dropbox.com/s/lhz9fclot9n0qpx/fade.log?dl=0

So, is there a way to make it work with all PDF readers? Not sure it matters, but I can draw something similar with inkscape (just setting border fill to gradient) and it works fine.

filippo
  • 598

1 Answers1

1

Workaround:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}
  \fill[black, path fading=east] (-0.07,-0.07) rectangle (2.07,1.07);
    \node at (1, 0.5) {\Large\bfseries fading};
  \fill[purple, path fading=east] (0,0) rectangle (2,1);
\end{tikzpicture}
\end{document}

enter image description here

  • Great, now I just need to find a way to make it work with more complex paths. Do you know if is there a way to scale a path with respect to its center? That way I could use just duplicate the path, scale it up, and fill it with black – filippo Jan 26 '18 at 15:27
  • @filippo Maybe something like https://tex.stackexchange.com/a/399382/36296 could help – samcarter_is_at_topanswers.xyz Jan 26 '18 at 15:54
  • thank you that's perfect (at least for paths with proper symmetry) – filippo Jan 26 '18 at 16:18