Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to improve the glowing effect in the MWE below. As shown in the output there is like a sharp transition between the white circle in the center and the surrounding halo, which does not give the desired effect of having a smooth transition to simulate a natural light. I don't know how TikZ enthusiasts would approach this matter in order to improve the glowing effect? in other words, how far TikZ can go with the glowing effect?

Note
Please keep the diameter of all circles fixed, but you can adjust fading width, the most important point is not to show the empty space at the confluence of the colored circles, I want it to be completely hidden behind the white glowing light, I hope.

MWE Code

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone} 
\usepackage{graphicx,xcolor}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,shadings,decorations.text,shadows,fadings} 
\tikzfading[name=fade out,inner color=transparent!0,outer color=transparent!70]
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,very thick,>=triangle 45,x=1.0cm,y=1.0cm,align=center]

\draw [color=black,fill=blue!50!black,fill opacity=1.0] (0,2) circle (1.4cm) node (12oclock){}; 
\draw [color=black,fill=blue!20!black,fill opacity=1.0] (-1.9,0.62) circle (1.4cm) node (10oclock){};
\draw [color=black,fill=green!50!black,fill opacity=1.0] (-1.18,-1.62) circle (1.4cm) node (8oclock){};
\draw [color=black,fill=orange!50!yellow,fill opacity=1.0] (1.18,-1.62) circle (1.4cm) node (5oclock){};
\draw [color=black,fill=red,fill opacity=1.0] (1.9,0.62) circle (1.4cm) node (2oclock){};
\draw [color=white,fill=white,fill opacity=1] (0,0) circle (0.8cm);

\fill [white,circular glow={fill=white}] (0,0) circle (0.8cm); % the glowing effect
\fill [white,path fading=fade out] (0,0) circle (1.6cm); %the fading effect

\end{tikzpicture}
\end{document}

MWE Output
enter image description here

share|improve this question
    
you should also try different pdf viewers just to be sure. –  percusse May 17 at 2:04

3 Answers 3

up vote 10 down vote accepted

Edit

Here is a second (better?) solution:

enter image description here

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone} 
\usepackage{graphicx,xcolor}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,shadings,decorations.text,shadows,fadings} 

\pgfdeclareradialshading{glow}{\pgfpoint{0cm}{0cm}}{
  color(0mm)=(white);
  color(3mm)=(white);
  color(7mm)=(black);
  color(10mm)=(black)
}

\begin{tikzfadingfrompicture}[name=glow fading]
  \shade [shading=glow] (0,0) circle (1);
\end{tikzfadingfrompicture}

\begin{document}
\begin{tikzpicture}[very thick]
  \draw [draw=black,fill=blue!50!black,fill opacity=1.0] (0,2) circle (1.4cm) node (12oclock){}; 
  \draw [draw=black,fill=blue!20!black,fill opacity=1.0] (-1.9,0.62) circle (1.4cm) node (10oclock){};
  \draw [draw=black,fill=green!50!black,fill opacity=1.0] (-1.18,-1.62) circle (1.4cm) node (8oclock){};
  \draw [draw=black,fill=orange!50!yellow,fill opacity=1.0] (1.18,-1.62) circle (1.4cm) node (5oclock){};
  \draw [draw=black,fill=red,fill opacity=1.0] (1.9,0.62) circle (1.4cm) node (2oclock){};

  \fill [white,path fading=glow fading] (0,0) circle (3); %the fading effect
\end{tikzpicture}
\end{document}

First proposition

Here is a solution:

enter image description here

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone} 
\usepackage{graphicx,xcolor}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,shadings,decorations.text,shadows,fadings} 
\tikzfading[name=fade out,inner color=transparent!0,outer color=transparent!100]
\begin{document}
\begin{tikzpicture}[very thick]
  \draw [draw=black,fill=blue!50!black,fill opacity=1.0] (0,2) circle (1.4cm) node (12oclock){}; 
  \draw [draw=black,fill=blue!20!black,fill opacity=1.0] (-1.9,0.62) circle (1.4cm) node (10oclock){};
  \draw [draw=black,fill=green!50!black,fill opacity=1.0] (-1.18,-1.62) circle (1.4cm) node (8oclock){};
  \draw [draw=black,fill=orange!50!yellow,fill opacity=1.0] (1.18,-1.62) circle (1.4cm) node (5oclock){};
  \draw [draw=black,fill=red,fill opacity=1.0] (1.9,0.62) circle (1.4cm) node (2oclock){};
  \foreach \radius in {1,...,10}{
    \fill [white,path fading=fade out] (0,0) circle (30mm-3*\radius mm); %the fading effect
  }
\end{tikzpicture}
\end{document}
share|improve this answer
    
to be honest, I was about to ask you for the second solution, which is definitely better, thanks a lot. –  doctorate May 17 at 12:22

It is dark during night isn't it?

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone}
\usepackage{graphicx,xcolor}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,fadings}
\tikzfading[name=fade inside,inner color=transparent!100,outer color=transparent!20]
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,very thick,>=triangle 45,x=1.0cm,y=1.0cm,align=center]

\draw [fill=blue!50!black,fill opacity=1.0] (0,2) circle (1.4cm) node (12oclock){};
\draw [fill=blue!20!black,fill opacity=1.0] (-1.9,0.62) circle (1.4cm) node (10oclock){};
\draw [fill=green!50!black,fill opacity=1.0] (-1.18,-1.62) circle (1.4cm) node (8oclock){};
\draw [fill=orange!50!yellow,fill opacity=1.0] (1.18,-1.62) circle (1.4cm) node (5oclock){};
\draw [fill=red,fill opacity=1.0] (1.9,0.62) circle (1.4cm) node (2oclock){};
%%\path [fill=white,fill opacity=1] (0,0) circle (0.7cm);  %% optional may remove it.

\fill[black, path fading=fade inside] (current bounding box.south west) rectangle  (current bounding box.north east); % the glowing effect
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer

Just 4 fun with PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}

\def\glower#1#2#3{%
        \pscustom[linestyle=none,fillcolor=white,opacity=#3,fillstyle=eofill]
        {
            \pscircle{!4 1 #1 sub mul}
            \moveto(!4 1 #2 sub mul 0)
            \pscircle{!4 1 #2 sub mul}
        }}

\begin{document}

\begin{pspicture}[fillstyle=solid,dimen=m](-5,-5)(5,5)
    \foreach \a/\c in {18/red,90/blue,162/black,234/green,306/yellow}{\pscircle[fillcolor=\c](2;\a){2}}
    \multido{\nO=0.00+0.01,\nI=0.01+0.01}{81}{\glower{\nI}{\nO}{\nO}}\glower{1}{.81}{1}
\end{pspicture}
\end{document}

enter image description here

Version 2

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}

\def\glower#1#2#3{%
        \pscustom[linestyle=none,fillcolor=white,opacity=#3,fillstyle=eofill]
        {
            \pscircle{!3 1 #1 sub mul}
            \moveto(!3 1 #2 sub mul 0)
            \pscircle{!3 1 #2 sub mul}
        }}

\begin{document}

\begin{pspicture}[fillstyle=solid,dimen=m](-5,-5)(5,5)
    \foreach \a/\c in {18/red,90/blue,162/black,234/green,306/yellow}{\pscircle[fillcolor=\c](2.5;\a){2}}
    \multido{\nO=0.000+0.001,\nI=0.001+0.001,\n=0.0000+0.0015}{501}{\glower{\nI}{\nO}{\n}}\glower{1}{.501}{1}
\end{pspicture}
\end{document}

enter image description here

share|improve this answer
    
\moveto(!4 1 #2 sub mul 0) is still needed because \pscircle and \psellipse do not move the current point to its starting point before drawing. –  Please don't touch May 17 at 12:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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