4

I would like to have more control on fading in TikZ. Consider fading a circle radially outwards, which can be done by using inner color=transparent!0 and outer color=transparent!100. Is there a way to start the fading from the middle outwards? How can the \tikzfading be customised to account for this?

\documentclass[tikz]{standalone}
\usepackage{pgf,pgfplots}
\usetikzlibrary{fadings} 

\tikzfading[name=fade out, 
    inner color=transparent!0,
    outer color=transparent!100]      

\begin{document} 

\begin{tikzpicture}
\fill[red,opacity=0.9,path fading=fade out, draw=none] (0,0) circle (0.52);
\end{tikzpicture}

\end{document}
Sid
  • 1,806

1 Answers1

6

Yes, of course. The way that works is that you declare a shading but with the color replaced by pgftransparent. Here is an example.

\documentclass[tikz]{standalone}
\usetikzlibrary{fadings} 
\pgfdeclareradialshading{tikzfadeSid}{\pgfpointorigin}{%
  color(0pt)=(pgftransparent!0); color(12.5bp)=(pgftransparent!0);
  color(25bp)=(pgftransparent!50); 
  color(37.5bp)=(pgftransparent!95); 
  color(50bp)=(pgftransparent!100)}%
\pgfdeclarefading{custom fade out}{\pgfuseshading{tikzfadeSid}}%

\begin{document} 
\begin{tikzpicture}
\fill[red,opacity=0.9,path fading=custom fade out, draw=none] (0,0) 
circle[radius=0.52];
\end{tikzpicture}
\end{document}

enter image description here

As long as you do not add something in the background, it might be simpler to just use a shading instead.