Draw a shaded wheel in Tikz

You can define a new shading, e.g., \pgfdeclareradialshading{ring}, like this:

\documentclass[tikz, border=5pt]{standalone}

\pgfdeclareradialshading{ring}{\pgfpoint{0cm}{0cm}}%
{rgb(0cm)=(1,1,1);
rgb(.6666cm)=(.6,.5,.5);
rgb(1cm)=(1,1,1)}

\begin{document}
   \begin{tikzpicture}
      \draw[shading=ring, even odd rule] (0,0) circle (1.5) circle (1);
   \end{tikzpicture}
\end{document}

\end{document}

enter image description here


To get a precise radial shading, you must take into account the following extract and the pictures from p.1086 of pgfmanual (v3.0.1a):

The shading is scaled and translated such that the point (50bp, 50bp), which is the middle of the shading, is at the middle of the path and such that the point (25bp, 25bp) is at the lower left corner of the path and that (75bp, 75bp) is at upper right corner.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}

\pgfdeclareradialshading{gray ring}{\pgfpoint{0cm}{0cm}}%
{
  color(0bp)=(gray);
  color(16.66666bp)=(gray); % = 1/1.5 * 25bp
  color(20.83333bp)=(gray!10); % = 1.25/1.5 * 25bp
  color(25bp)=(gray);
  color(50bp)=(gray)
}

\begin{document}
\begin{tikzpicture}
  \shade[even odd rule,shading=gray ring]
  (0,0) circle (1.5) circle(1);
\end{tikzpicture}
\end{document}

enter image description here


Just add a draw command for the inner circle:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
   \begin{tikzpicture}
       \shade[outer color=gray,middle color=red,inner color=gray] [even odd rule] (0,0) circle (1.5) (0,0) circle (1);
       \draw[fill=blue!50, radius=1.5,draw=gray] (0,0) circle (1);
   \end{tikzpicture}
\end{document}

I have added draw=gray so that the colour of the border to the inner circle matches the shaded region.

enter image description here

EDIT

I suspect that this is ot what you want, but the middle color is being overridden by the inner color=gray thar follows it. You need to put middle color last in order for it to work. The code:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
   \begin{tikzpicture}
       \shade[outer color=gray,inner color=gray, middle color=gray!10, even odd rule](0,0) circle (1.5) circle (1.25);
   \end{tikzpicture}
\end{document}

produces

enter image description here

I think that you need AboAmmar's approach!

Tags:

Tikz Pgf