5

I would like to have voltage and current sources filled with color inside them as in v_s and \beta{}v_{\pi} automatically by defining macros in the preamble. Can anyone suggest me how to do it? By default, they don't fill with color and coloring the way I have done below will simply make file bigger with codes if I have many dependent and independent sources:

\documentclass[border=2pt]{standalone}[2015/09/17]
\usepackage{tikz}
\usetikzlibrary{arrows, circuits.ee.IEC, positioning}
\usepackage[american voltages, american currents,siunitx]{circuitikz}

\begin{document}
\begin{tikzpicture}[circuit ee  IEC, x=3.5cm, y=3.5cm, color=blue!50!black]
    \fill [cyan!40, opacity=0.4] (0,0.4) circle (2.7ex); % color fill v_s
    \draw (1.8,0.4) node[rectangle,draw,xscale=2.8,yscale=2.8,rotate=45,fill=cyan!40,opacity=0.5]{}; % cI

    \draw (2.8,0.0) to (0.0,0.0) to [V, l=$v_s$, color=blue!50!black] (0.0,0.8);
    \draw (0.0,0.8) to [R, l=300<\milli\ohm>, color=blue!50!black] (0.8,0.8) node[circ]{};
    \draw (0.8,0.8) to [cV, l_=$\alpha{}v_{oc}$, color=blue!50!black] (0.8,0.0) node[circ]{};
    \draw (0.8,0.8) to (1.3,0.8) to [R, l_=5<\kilo\ohm>, color=blue!50!black] (1.3,0.0) node[circ]{};
    \draw (2.8,0.8) node[ocirc]{} to (1.8,0.8) to [cI, l=$\beta{}v_{\pi}$, color=blue!50!black] (1.8,0.0) node[circ]{};
    \draw (2.4,0.8) node[circ]{} to [R, l=1<\kilo\ohm>, color=blue!50!black] (2.4,0.0) node[circ]{}
        to (2.8,0.0) node[ocirc]{};

    \draw (1.45,0.6) node[magenta]{$+$};
    \draw (1.45,0.4) node[magenta]{$v_{\pi}$};
    \draw (1.45,0.2) node[magenta]{$-$};

    \draw (2.8,0.7) node[magenta]{$+$};
    \draw (2.8,0.4) node[magenta]{$v_{oc}$};
    \draw (2.8,0.1) node[magenta]{$-$};
\end{tikzpicture}
\end{document}

enter image description here.

I finally found from Gonzalo's tips:

\documentclass[border=2pt]{standalone}[2015/09/17]
\usepackage{tikz}
\usetikzlibrary{arrows, circuits.ee.IEC, positioning}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\usetikzlibrary{backgrounds}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourceam/height}}{vsourceAM}              {\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/vsourceam/width}}{%
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{$+$}
   \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{$-$}

\begin{pgfonlayer}{background}
      \pgfsetfillcolor{vsourceAMcolor}
      \pgfusepath{stroke,draw,fill}
\end{pgfonlayer} 
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/isourceam/height}}{isourceAM}              {\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/isourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\begin{pgfonlayer}{background}
     \pgfsetfillcolor{isourceAMcolor}
     \pgfusepath{stroke,draw,fill}
\end{pgfonlayer}

     \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
     \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
     \pgfusepath{draw,fill}
     \pgfscope
     \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
     \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
     \endpgfscope
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourceam/height}}{cvsourceAM}       {\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cvsourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{cvsourceAMcolor}
    \pgfusepath{stroke,draw,fill}
\end{pgfonlayer}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@down]{$+$}
\pgftext[top,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@up]{$-$}
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cisourceam/height}}{cisourceAM}       {\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cisourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

   \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
     \pgfsetfillcolor{cisourceAMcolor}
     \pgfusepath{stroke,draw,fill}
\end{pgfonlayer}

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw,fill}
    \pgfscope
    \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
    \endpgfscope
}
\makeatother

\colorlet{vsourceAMcolor}{red!10}
\colorlet{isourceAMcolor}{red!10}
\colorlet{cvsourceAMcolor}{cyan!10}
\colorlet{cisourceAMcolor}{cyan!10}

\begin{document}
\begin{tikzpicture}[circuit ee  IEC, x=3.5cm, y=3.5cm, color=blue!50!black]
    \draw (2.8,0.0) to (0.0,0.0) to [V, l=$v_s$, color=blue!50!black] (0.0,0.8);
    \draw (0.0,0.8) to [R, l=300<\milli\ohm>, color=blue!50!black] (0.8,0.8) node[circ]{};
    \draw (0.8,0.0) to [cV, l=$\alpha{}v_{oc}$, color=blue!50!black] (0.8,0.8) node[circ]{};
    \draw (0.8,0.8) to (1.3,0.8) to [R, l_=5<\kilo\ohm>, color=blue!50!black] (1.3,0.0) node[circ]{};
    \draw (2.8,0.8) node[ocirc]{} to (1.8,0.8) to [cI, l=$\beta{}v_{\pi}$, color=blue!50!black] (1.8,0.0) node[circ]{};
    \draw (2.4,0.8) node[circ]{} to [I, l=1<\ampere>, color=blue!50!black] (2.4,0.0) node[circ]{}
        to (2.8,0.0) node[ocirc]{};

    \draw (1.45,0.6) node[magenta]{$+$};
    \draw (1.45,0.4) node[magenta]{$v_{\pi}$};
    \draw (1.45,0.2) node[magenta]{$-$};

    \draw (2.8,0.7) node[magenta]{$+$};
    \draw (2.8,0.4) node[magenta]{$v_{oc}$};
    \draw (2.8,0.1) node[magenta]{$-$};
\end{tikzpicture}
\end{document}

enter image description here

I also thank Harish who quickly responded though opacity created little problem in visibility/sharpness on circuit elements/labels/info.

Finally, I could do this way: thanks

\documentclass[border=2pt]{standalone}[2015/09/18]
\usepackage{tikz}
\usetikzlibrary{arrows, circuits.ee.IEC, positioning}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\usetikzlibrary{backgrounds}

% default color
\colorlet{vsourceAMcolorfill}{white}
\colorlet{vsourceAMcolordraw}{black}
\colorlet{cvsourceAMcolorfill}{white}
\colorlet{cvsourceAMcolordraw}{black}
\colorlet{isourceAMcolorfill}{white}
\colorlet{isourceAMcolordraw}{black}
\colorlet{cisourceAMcolorfill}{white}
\colorlet{cisourceAMcolordraw}{black}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourceam/height}}{vsourceAM}              {\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/vsourceam/width}}{%
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{$+$}
   \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{$-$}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{vsourceAMcolorfill}
    \pgfsetstrokecolor{vsourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer} 
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/isourceam/height}}{isourceAM}              {\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/isourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{isourceAMcolorfill}
    \pgfsetstrokecolor{isourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer}

     \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
     \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
     \pgfusepath{draw,fill}
     \pgfscope
     \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
     \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
     \endpgfscope
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourceam/height}}{cvsourceAM}       {\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cvsourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{cvsourceAMcolorfill}
    \pgfsetstrokecolor{cvsourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@down]{$+$}
\pgftext[top,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@up]{$-$}
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cisourceam/height}}{cisourceAM}       {\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cisourceam/width}}{%

\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

   \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
   \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{cisourceAMcolorfill}
    \pgfsetstrokecolor{cisourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer}

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw,fill}
    \pgfscope
    \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
    \endpgfscope
}
\makeatother

\begin{document}
\begin{tikzpicture}[circuit ee  IEC, x=3.5cm, y=3.5cm]
    \draw 
        (0,0) to [V, l=$v_s$] (0,1)
        (0.6,0) to [cV, l=$\alpha{}v_x$] (0.6,1)
        (1.1,0) to [I, l=$I_s$] (1.1,1)
        (1.7,0) to [cI, l=$\alpha{}i_{sc}$] (1.7,1);
\end{tikzpicture}

\colorlet{vsourceAMcolorfill}{red!20}
\colorlet{vsourceAMcolordraw}{red}
\colorlet{cvsourceAMcolorfill}{olive!20}
\colorlet{cvsourceAMcolordraw}{olive}
\colorlet{isourceAMcolorfill}{red!20}
\colorlet{isourceAMcolordraw}{red}
\colorlet{cisourceAMcolorfill}{olive!20}
\colorlet{cisourceAMcolordraw}{olive} 

\begin{tikzpicture}[circuit ee  IEC, x=3.5cm, y=3.5cm]
    \draw 
        (0,0) to [V, l=$v_s$] (0,1)
        (0.6,0) to [cV, l=$\alpha{}v_x$] (0.6,1)
        (1.1,0) to [I, l=$I_s$] (1.1,1)
        (1.7,0) to [cI, l=$\alpha{}i_{sc}$] (1.7,1);
\end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

7

Update

Now there's control over the filling and the drawing colors:

\documentclass[dvipsnames,x11names,svgnames]{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows, circuits.ee.IEC, positioning}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\usetikzlibrary{backgrounds}

\colorlet{vsourceAMcolorfill}{cyan!50}
\colorlet{vsourceAMcolordraw}{black!50!black}
\colorlet{cisourceAMcolorfill}{cyan!50}
\colorlet{cisourceAMcolordraw}{black!50!black}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourceam/height}}{vsourceAM}{\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/vsourceam/width}}{

    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{$+$}
    \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{$-$}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{vsourceAMcolorfill}
    \pgfsetstrokecolor{vsourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer}
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cisourceam/height}}{cisourceAM}{\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cisourceam/width}}{

    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{cisourceAMcolorfill}
    \pgfsetstrokecolor{cisourceAMcolordraw}
    \pgfusepath{stroke,fill}
\end{pgfonlayer}

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
    \pgfscope
        \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
    \endpgfscope
}
\makeatother

\begin{document}

\begin{tikzpicture}[circuit ee  IEC,color=blue!50!black]
    \draw 
    (0,0) to [V, l=$v_s$] (0,3)
    (2,3) to [cI, l=$\beta{}v_{\pi}$] (2,0);
\colorlet{vsourceAMcolorfill}{red!20}
\colorlet{vsourceAMcolordraw}{red}
\colorlet{cisourceAMcolorfill}{olive!20}
\colorlet{cisourceAMcolordraw}{olive}
    \draw 
    (5,0) to [V, l=$v_s$, color=blue!50!black] (5,3)
    (7,3) to [cI, l=$\beta{}v_{\pi}$,color=blue!50!black] (7,0);
\end{tikzpicture}

\end{document}

enter image description here

Here's one way to do it; use \definecolor or \colorlet to declare the colors to be used (vsourceAMcolor for the voltage source and cisourceAMcolor for the current source):

\documentclass[dvipsnames,x11names,svgnames]{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows, circuits.ee.IEC, positioning}
\usepackage[american voltages, american currents,siunitx]{circuitikz}
\usetikzlibrary{backgrounds}

\colorlet{vsourceAMcolor}{cyan!50}
\colorlet{cisourceAMcolor}{cyan!50}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourceam/height}}{vsourceAM}{\ctikzvalof{bipoles/vsourceam/height}}{\ctikzvalof{bipoles/vsourceam/width}}{

    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}

\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{$+$}
    \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{$-$}
    
\begin{pgfonlayer}{background}
    \pgfsetfillcolor{vsourceAMcolor}
    \pgfusepath{stroke,draw,fill}
\end{pgfonlayer}
}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cisourceam/height}}{cisourceAM}{\ctikzvalof{bipoles/cisourceam/height}}{\ctikzvalof{bipoles/cisourceam/width}}{

    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
    
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}

\begin{pgfonlayer}{background}
    \pgfsetfillcolor{cisourceAMcolor}
    \pgfusepath{stroke,draw,fill}
\end{pgfonlayer}

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw,fill}
    \pgfscope
        \pgftransformshift{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfnode{currarrow}{center}{}{}{\pgfusepath{draw}}
    \endpgfscope
}
\makeatother

\begin{document}

\begin{tikzpicture}[circuit ee  IEC,color=blue!50!black]
    \draw 
    (0,0) to [V, l=$v_s$, color=blue!50!black] (0,3)
    (2,3) to [cI, l=$\beta{}v_{\pi}$,color=blue!50!black] (2,0);
\colorlet{vsourceAMcolor}{red!20}
\colorlet{cisourceAMcolor}{olive!50}
    \draw 
    (5,0) to [V, l=$v_s$, color=blue!50!black] (5,3)
    (7,3) to [cI, l=$\beta{}v_{\pi}$,color=blue!50!black] (7,0);
\end{tikzpicture}

\end{document}

The result:

enter image description here

The problem is the for those shapes, the package uses \pgfpath{draw} so it draws the shape and gives no possibility for filling. I redefined the shapes to allow for a filling performed in the background layer.

4
  • Thanks a lot Gonzalo. Finally you help me get the problem solved as always. I am reproducing above right below the original MWE what I learned from you.
    – Khaaba
    Sep 17, 2015 at 18:33
  • @Khaaba You're welcome. Glad I could help. Sep 17, 2015 at 19:49
  • @Khaaba I updated my answer adding control over the drawing colors also. Sep 17, 2015 at 23:17
  • I noted the changes.
    – Khaaba
    Sep 18, 2015 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .