# How to fill a shape with two colors with a varying ratio using TikZ?

I want to fill a TikZ shape/node with two colors that are spitted horizontally and be able to adjust the ratio between them like as follows (similar to a loading bar):

I tried to modify this example that uses shading but the rendering is different and always produces some color mixing:

• have a look athe answer below – js bibra Feb 23 at 5:52
• is there something else required -- would you like to accept the answer – js bibra Feb 23 at 7:17
• is there something else required -- would you like to accept the answer – js bibra Feb 23 at 7:17
• @jsbibra This is exactly what I was looking for, thanks! – DurandA Feb 23 at 11:03

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}[my node/.style={draw, cloud, cloud ignores aspect, }]
\node[my node] (a1)  {Text};

\end{tikzpicture}

\begin{tikzpicture}[fill fraction/.style n args={2}{path picture={
\fill[#1] (path picture bounding box.south west) rectangle
($(path picture bounding box.north west)!#2!(path picture bounding box.north east)$);}}]

\draw (4, 0) node[cloud, cloud ignores aspect,draw,fill=blue, fill fraction={green}{0.7}] {Some
other text};
\end{tikzpicture}
\end{document}


EDIT

The long text spoils the shape of the cloud so an edit

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}[my node/.style={draw, cloud, cloud ignores aspect, }]
\node[my node] (a1)  {Text};

\end{tikzpicture}

\begin{tikzpicture}[fill fraction/.style n args={2}{path picture={
\fill[#1] (path picture bounding box.south west) rectangle
($(path picture bounding box.north west)!#2!(path picture bounding box.north east)$);}}]

\draw (4, 0) node[cloud, cloud ignores aspect,draw,fill=blue, fill fraction={green}{0.7}] {text};
\end{tikzpicture}
\end{document}


results in