1

i have some tikz code like this one :

        \tikzset{
            bloc/.style={
                anchor=south west, 
                draw, 
                minimum height=0.7cm, 
                align=left,
                font=\small
            },
        }


\begin{tikzpicture}
    \node[bloc, minimum width=5.5cm, 
          fading transform={xshift=-3cm}, 
          left color=green!60!black!80, 
          right color=red!60]  
    at (-9,0.5) {Initialize process};
\end{tikzpicture}

I would like to change the fading transform part to have different proportions. For example, i would like to have 80% of the node to be in green, and only 20% of the node in red. But i don't find any way to to that.

Do you have some tips to do that ?

My final goal is to make a roadmap and to indicate on it how many tasks are done or partially done.

The full code :

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \tikzset{
        bloc/.style={
            anchor=south west, 
            draw, 
            minimum height=0.7cm, 
            align=left,
            font=\small
        },
    }

\begin{tikzpicture}
\node[bloc, minimum width=5.5cm, 
      fading transform={xshift=-3cm}, 
      left color=green!60!black!80, 
      right color=red!60]  
at (-9,0.5) {Initialize process};

\end{tikzpicture}
\end{document}
user47106
  • 123
  • 4

1 Answers1

2

Using a custom shading allows to control the positions of the colors:

\documentclass{article}

\usepackage{tikz}

\begin{document}
    \tikzset{
        bloc/.style={
            anchor=south west, 
            draw, 
            minimum height=0.7cm, 
            align=left,
            font=\small
        },
    }



\begin{tikzpicture}
\pgfdeclarehorizontalshading{myshadingA}{3cm}{
    color(0cm)=(green); 
    color(1.44cm)=(green); 
    color(1.8cm)=(red)
}
\node[bloc, minimum width=5.5cm, 
      shading=myshadingA]  
at (-9,0.5) {Initialize process};

\end{tikzpicture}
\end{document}

enter image description here

Pizzagne
  • 188
  • Thank you. could you explain more the useage of the color list options ? I really don't understand correctly this page : https://stuff.mit.edu/afs/athena/contrib/tex-contrib/beamer/pgf-1.01/doc/generic/pgf/version-for-tex4ht/en/pgfmanualse28.html – user47106 Jun 24 '19 at 12:22
  • @user47106 You just specify at which position it should have which color and tikz will then interpolate between these colors – Pizzagne Jun 24 '19 at 12:50