[Tex/LaTex] TikZ: Rectangle with diagonal fill (two colors)

tikz-pgf

I'm trying to fill half of my rectangle with a green color. I would like the transition to be along a diagonal of the rectangle.

Here is the code I have currently

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}
\node [rectangle,draw,thick,text width=1.5cm,minimum height=1.5cm,
        text centered,rounded corners, drop shadow, fill=yellow, name = re] {Test};
\end{tikzpicture}
\end{document}

This (of course) gives me an only yellow rectangle. I would like something like this instead.

Desired output

I have looked at http://www.texample.net/tikz/examples/rectangle-node-with-diagonal-fill/, but I didn't get it to work with the drop shadow (and it seems like a lot of code for a simple task).

I'm considering drawing an invisible triangle under the rectangle with clipping, but I'm not sure how to do that, or if it's the smartest way.

Best Answer

A short answer with some trick. Rectangle is drawn twice:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}
\node [rectangle,draw,text width=1.5cm,minimum height=1.5cm,
        text centered,rounded corners,name = re] {};
       \filldraw[yellow!80,drop shadow][] (re.south west)
        [rounded corners=4pt] -- (re.south east)
        [rounded corners=4pt] -- (re.north east)--cycle
        ;
        \filldraw[green!80][] (re.south west)
        [rounded corners=4pt] -- (re.north west)
        [rounded corners=4pt] -- (re.north east)--cycle
        ;
\node [rectangle,draw,thick, text width=1.5cm,minimum height=1.5cm,
        text centered,rounded corners,name = re] {Text};      
\end{tikzpicture}
\end{document}

enter image description here

EDIT: This edit offers by OP. He/she edit my answer and found a new solution.

Now only drawing one rectangle, and diagonal is completely straight.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\tikzset{
diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.south west) -|
                         (path picture bounding box.north east) -- cycle;}},
reversed diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.north west) |- 
                         (path picture bounding box.south east) -- cycle;}}
}
% (reversed) diagonal fill={lower color}{upper color}
\begin{document}
\begin{tikzpicture}
\node[diagonal fill={yellow}{green!80},
      text width=1.5cm, minimum height=1.5cm,
      text centered, rounded corners, draw, drop shadow]{Text};
\end{tikzpicture}
\end{document}

enter image description here