The benefit of decoration is that it could help you place shadings properly. But before that, let us define a flexible shading

\pgfdeclareverticalshading[base color]{cylinder}{1000bp}{
color(0.000bp)=(black!75!base color);
color(22.773bp)=(black!75!base color);
color(45.525bp)=(black!3.893!base color);
color(53.986bp)=(white!26.261!base color);
color(59.561bp)=(white!26.261!base color);
color(68.022bp)=(black!3.893!base color);
color(90.773bp)=(black!75!base color);
color(100.000bp)=(black!75!base color)}
\pgfutil@colorlet{base color}{green}
\pgfuseshading{cylinder}
Then we try to utilize this shading in a decoration. There are many parameters
start at
is the starting position.
end at
is the ending position.
start by
determines if the shape is convex or concave at the starting position.
(1
: convex; .1
: slightly convex; -1
: concave)
end by
works similarly
The problem here is that the shading does not rotate with us. (By "us" I mean the decoration engine.) So I need to modify the behavior of \pgfshadepath
-- I called it \pgfshadepath@revise
.

\pgfkeys{
/pgf/decoration/.cd,
start at/.code={\pgfmathsetmacro\pgfdecorationstartat{#1}},
start at=.25,
end at/.code={\pgfmathsetmacro\pgfdecorationendat{#1}},
end at=.75,
start by/.code={\pgfmathsetmacro\pgfdecorationstartby{#1}},
start by=-.5,
end by/.code={\pgfmathsetmacro\pgfdecorationendby{#1}},
end by=-.5,
base color/.code=\pgfutil@colorlet{base color}{#1},
base color=white,
amplitude=1cm
}
\newdimen\pgf@xd
\newdimen\pgf@xe
\newdimen\pgf@yd
\pgfdeclaredecoration{cylinder}{initial}
{
\state{initial}[width=\pgfdecorationstartat*\pgfdecoratedinputsegmentlength,next state=draw]
{}
\state{draw}[width=0pt,next state=final]
{
\pgf@xe\pgfdecorationsegmentamplitude pt
\pgf@xd\pgfdecorationstartby\pgf@xe \pgf@xe\pgfdecorationendby\pgf@xe
\pgf@yd\pgfdecorationsegmentamplitude pt
\pgfpathmoveto{\pgfqpoint{0pt}{\pgf@yd}}
\pgfpatharcaxes{90}{270}{\pgfqpoint{\pgf@xd}{0pt}}{\pgfqpoint{0pt}{\pgf@yd}}
\pgfpathlineto{\pgfpoint{(\pgfdecorationendat-\pgfdecorationstartat)*\pgfdecoratedinputsegmentlength}{-\pgf@yd}}
\pgfpatharcaxes{-90}{90}{\pgfqpoint{\pgf@xe}{0pt}}{\pgfqpoint{0pt}{\pgf@yd}}
\pgfclosepath
\pgftransformyscale{\pgf@yd/50bp}
\pgfgettransform\pgfcurrenttransform
\pgfsetadditionalshadetransform{\pgfsettransform\pgfcurrenttransform}
\pgfshadepath@revise{cylinder}
\pgfusepath{}
}
\state{final}
{}
}
\def\pgfshadepath@revise#1{%
\begingroup%
\pgfsys@beginscope%
\pgfsyssoftpath@invokecurrentpath%
\pgfsys@clipnext%
\pgfsys@discardpath%
\ifx\pgf@shade@extra@transform\pgfutil@empty%
\else%
\pgflowlevel{\pgf@shade@extra@transform}%
\fi%
\pgfuseshading{#1}%
\pgfsys@endscope%
\endgroup%
}
\tikz{
\draw(-4,-1)--(4,1);
\draw decorate[decoration=cylinder]{(-4,-1)--(4,1)};
}
We can decorate the same path multiple times.

\tikz{
\draw(-4,-1)to[
to path={
decorate[decoration={cylinder,base color=red ,start at=.0 ,end at=.2 ,start by= .5,end by=-.5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=blue ,start at=.25,end at=.45,start by= .5,end by= .5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=white,start at=.55,end at=.75,start by=-.5,end by= .5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=black,start at=.8,end at=1 ,start by=-.5,end by=-.5}]{(\tikztostart)--(\tikztotarget)}
}
](4,1);
}
In your case we need only two times. We can write a parser. Here ) red (
means that the cylinder is in red, and is concave at both side. If you change it to ( blue )
, it becomes a blue cylinder convex at both side. The number between two cylinders represents the position of the "cut".

\tikzset{
bond/.code args={#1 #2 #3 #4 #5 #6 #7}{
\if#1|\edef\Astartby{0}\else\if#1(\edef\Astartby{.5}\else\if#1)\edef\Astartby{-.5}\else\edef\Astartby{#1}\fi\fi\fi
\if#3|\edef\Aendby{ 0}\else\if#3(\edef\Aendby{ -.5}\else\if#3)\edef\Aendby{ .5}\else\edef\Aendby{ #3}\fi\fi\fi
\if#5|\edef\Bstartby{0}\else\if#5(\edef\Bstartby{.5}\else\if#5)\edef\Bstartby{-.5}\else\edef\Bstartby{#5}\fi\fi\fi
\if#7|\edef\Bendby{ 0}\else\if#7(\edef\Bendby{ -.5}\else\if#7)\edef\Bendby{ .5}\else\edef\Bendby{ #7}\fi\fi\fi
\tikzset{
to path={
decorate[decoration={cylinder,base color=#2,start at=0,end at=#4,start by=\Astartby,end by=\Aendby}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=#6,start at=#4,end at=1,start by=\Bstartby,end by=\Bendby}]{(\tikztostart)--(\tikztotarget)}
}
}
}
}
\tikz{
\draw(-4,-1)to[bond=) red ( .4 ) white (](4,1);
}
Now go into Chemistry. We can define the style of bonds between different pairs of atoms. This is Urea, only that the double bond between carbon an nitrogen is not drawn properly.

\tikzset{
C-O/.style={bond=( black | .4 | red )},
C-N/.style={bond=( black | .45 | blue )},
N-H/.style={bond=( blue | .5 | white )},
C/.style={circle,shade,minimum size=5cm,ball color=black},
O/.style={circle,shade,minimum size=4cm,ball color=red},
H/.style={circle,shade,minimum size=3cm,ball color=white},
N/.style={circle,shade,minimum size=4.5cm,ball color=blue}
}
\tikz{
\path(0,0)node[C](C1){}(0,10)node[O](O1){}(9,-3)node[N](N1){}(-9,-3)node[N](N2){}(9,-8)node[H](H1){}(13,0)node[H](H2){}(-9,-8)node[H](H3){}(-13,0)node[H](H4){};
\path(C1)to[C-O](O1)(C1)to[C-N](N1)(C1)to[C-N](N2)(N1)to[N-H](H1)(N1)to[N-H](H2)(N2)to[N-H](H3)(N2)to[N-H](H4);
}
With our parser, we can indicate the 3D structure by the convexity of cylinders. This is methane.

\tikzset{
C>H/.style={bond=( black ) .4 ) white )},
C<H/.style={bond=( black ( .4 ( white )}
}
\tikz{
\path(0,0)node[C](C1){}(8,0)node[H](H1){}(-8,0)node[H](H2){}(0,8)node[H](H3){}(0,-8)node[H](H4){};
\path(C1)to[C>H](H1)(C1)to[C>H](H2)(C1)to[C<H](H3)(C1)to[C<H](H4);
}
Code
\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{decorations.pathmorphing,topaths}
\begin{document}
\makeatletter
\pgfdeclareverticalshading[base color]{cylinder}{1000bp}{
color(0.000bp)=(black!75!base color);
color(22.773bp)=(black!75!base color);
color(45.525bp)=(black!3.893!base color);
color(53.986bp)=(white!26.261!base color);
color(59.561bp)=(white!26.261!base color);
color(68.022bp)=(black!3.893!base color);
color(90.773bp)=(black!75!base color);
color(100.000bp)=(black!75!base color)}
\pgfutil@colorlet{base color}{green}
\pgfuseshading{cylinder}
\pgfkeys{
/pgf/decoration/.cd,
start at/.code={\pgfmathsetmacro\pgfdecorationstartat{#1}},
start at=.25,
end at/.code={\pgfmathsetmacro\pgfdecorationendat{#1}},
end at=.75,
start by/.code={\pgfmathsetmacro\pgfdecorationstartby{#1}},
start by=-.5,
end by/.code={\pgfmathsetmacro\pgfdecorationendby{#1}},
end by=-.5,
base color/.code=\pgfutil@colorlet{base color}{#1},
base color=white,
amplitude=1cm
}
\newdimen\pgf@xd
\newdimen\pgf@xe
\newdimen\pgf@yd
\pgfdeclaredecoration{cylinder}{initial}
{
\state{initial}[width=\pgfdecorationstartat*\pgfdecoratedinputsegmentlength,next state=draw]
{}
\state{draw}[width=0pt,next state=final]
{
\pgf@xe\pgfdecorationsegmentamplitude pt
\pgf@xd\pgfdecorationstartby\pgf@xe \pgf@xe\pgfdecorationendby\pgf@xe
\pgf@yd\pgfdecorationsegmentamplitude pt
\pgfpathmoveto{\pgfqpoint{0pt}{\pgf@yd}}
\pgfpatharcaxes{90}{270}{\pgfqpoint{\pgf@xd}{0pt}}{\pgfqpoint{0pt}{\pgf@yd}}
\pgfpathlineto{\pgfpoint{(\pgfdecorationendat-\pgfdecorationstartat)*\pgfdecoratedinputsegmentlength}{-\pgf@yd}}
\pgfpatharcaxes{-90}{90}{\pgfqpoint{\pgf@xe}{0pt}}{\pgfqpoint{0pt}{\pgf@yd}}
\pgfclosepath
\pgftransformyscale{\pgf@yd/50bp}
\pgfgettransform\pgfcurrenttransform
\pgfsetadditionalshadetransform{\pgfsettransform\pgfcurrenttransform}
\pgfshadepath@revise{cylinder}
\pgfusepath{}
}
\state{final}
{}
}
\def\pgfshadepath@revise#1{%
\begingroup%
\pgfsys@beginscope%
\pgfsyssoftpath@invokecurrentpath%
\pgfsys@clipnext%
\pgfsys@discardpath%
\ifx\pgf@shade@extra@transform\pgfutil@empty%
\else%
\pgflowlevel{\pgf@shade@extra@transform}%
\fi%
\pgfuseshading{#1}%
\pgfsys@endscope%
\endgroup%
}
\tikz{
\draw(-4,-1)--(4,1);
\draw decorate[decoration=cylinder]{(-4,-1)--(4,1)};
}
\tikz{
\draw(-4,-1)to[
to path={
decorate[decoration={cylinder,base color=red ,start at=.0 ,end at=.2 ,start by= .5,end by=-.5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=blue ,start at=.25,end at=.45,start by= .5,end by= .5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=white,start at=.55,end at=.75,start by=-.5,end by= .5}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=black,start at=.8,end at=1 ,start by=-.5,end by=-.5}]{(\tikztostart)--(\tikztotarget)}
}
](4,1);
}
\tikzset{
bond/.code args={#1 #2 #3 #4 #5 #6 #7}{
\if#1|\edef\Astartby{0}\else\if#1(\edef\Astartby{.5}\else\if#1)\edef\Astartby{-.5}\else\edef\Astartby{#1}\fi\fi\fi
\if#3|\edef\Aendby{ 0}\else\if#3(\edef\Aendby{ -.5}\else\if#3)\edef\Aendby{ .5}\else\edef\Aendby{ #3}\fi\fi\fi
\if#5|\edef\Bstartby{0}\else\if#5(\edef\Bstartby{.5}\else\if#5)\edef\Bstartby{-.5}\else\edef\Bstartby{#5}\fi\fi\fi
\if#7|\edef\Bendby{ 0}\else\if#7(\edef\Bendby{ -.5}\else\if#7)\edef\Bendby{ .5}\else\edef\Bendby{ #7}\fi\fi\fi
\tikzset{
to path={
decorate[decoration={cylinder,base color=#2,start at=0,end at=#4,start by=\Astartby,end by=\Aendby}]{(\tikztostart)--(\tikztotarget)}
decorate[decoration={cylinder,base color=#6,start at=#4,end at=1,start by=\Bstartby,end by=\Bendby}]{(\tikztostart)--(\tikztotarget)}
}
}
}
}
\tikz{
\draw(-4,-1)to[bond=) red ( .4 ) white (](4,1);
}
\tikzset{
C-O/.style={bond=( black | .4 | red )},
C-N/.style={bond=( black | .45 | blue )},
N-H/.style={bond=( blue | .5 | white )},
C/.style={circle,shade,minimum size=5cm,ball color=black},
O/.style={circle,shade,minimum size=4cm,ball color=red},
H/.style={circle,shade,minimum size=3cm,ball color=white},
N/.style={circle,shade,minimum size=4.5cm,ball color=blue}
}
\tikz{
\path(0,0)node[C](C1){}(0,10)node[O](O1){}(9,-3)node[N](N1){}(-9,-3)node[N](N2){}(9,-8)node[H](H1){}(13,0)node[H](H2){}(-9,-8)node[H](H3){}(-13,0)node[H](H4){};
\path(C1)to[C-O](O1)(C1)to[C-N](N1)(C1)to[C-N](N2)(N1)to[N-H](H1)(N1)to[N-H](H2)(N2)to[N-H](H3)(N2)to[N-H](H4);
}
\tikzset{
C>H/.style={bond=( black ) .4 ) white )},
C<H/.style={bond=( black ( .4 ( white )}
}
\tikz{
\path(0,0)node[C](C1){}(8,0)node[H](H1){}(-8,0)node[H](H2){}(0,8)node[H](H3){}(0,-8)node[H](H4){};
\path(C1)to[C>H](H1)(C1)to[C>H](H2)(C1)to[C<H](H3)(C1)to[C<H](H4);
}
\end{document}