8

I'm able to generate a tikz node with shadow (lower right) on the node, but this is different than shading not the entire node, but just the circle and edges like in the picture below.

enter image description here

The shadow on each edge is not really the problem, but the shadow in the nodes, that is dropped by the circle not only externally but also inside the node is something that I was not able to do in Tikz.

Minimum working tex:

\documentclass{article}
\usepackage{tikz}
\usepackage{fullpage}
\usetikzlibrary{shadows}

\begin{document}

\begin{tikzpicture}[main/.style = {draw, circle, text=black, fill=white, circular drop shadow={opacity=0.25}}] \node[main] (1) {$x_1$}; \end{tikzpicture}

\end{document}

enter image description here

1 Answers1

8

There are probably better ways to do this, but here I use a fuzzy ring 15 percent fading:

\documentclass[tikz, border=0.1cm]{standalone}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}[
main/.style = {draw, circle, text=black,  
preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 15 percent, opacity=0.25}
}] 
\node[main] (1) {$x_1$}; 
\end{tikzpicture} 
\end{document}

Node with fuzzy ring shadow


Edit:

The solution only works for circles and ellipses - not for e.g. polygons as shown here:

\documentclass[tikz, border=0.1cm]{standalone}
\usetikzlibrary {fadings, shapes}
\begin{document}
\begin{tikzpicture}[
main/.style = {draw, regular polygon, text=black,  
preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 15 percent, opacity=0.25}
}] 
\node[main] (1) {$x_1$}; 
\end{tikzpicture} 
\end{document}

Pentagon with bad shadow

To make a more general solution, one could implement a shifted version of glow as shown in this answer(by me): https://tex.stackexchange.com/a/569645/8650