# Custom shading pattern for tikz nodes

I'm looking for a way to achieve a different node shading than with the 'usual' way

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[top color=red, bottom color=green] {};
\end{tikzpicture}
\end{document}


In this example, there is a gradient, i.e. the middle color is different from the actual top and bottom color. Is it possible to change it, i.e. to have a hard separation of the colors (top= red, bottom=green) without any different middle color or to change the properties of the gradient?

• add middle color ? – percusse Feb 25 '16 at 15:45
• @percusse but then it wouldn't be 50% red, 50% green anymore, right? – bonanza Feb 25 '16 at 15:48
• then it is not a shading but a fill – percusse Feb 25 '16 at 16:06

Like this?

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,
append after command={
\pgfextra
\fill[green] (\tikzlastnode.south west) rectangle (\tikzlastnode.east);
\fill[red] (\tikzlastnode.north west) rectangle (\tikzlastnode.east);
\endpgfextra
}] {A};
\end{tikzpicture}
\end{document}