3

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}
5

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.