% Copyright 2007-2009 by Massimo Redaelli
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/LICENSE for more details.

%% Generic macro for defining a bipole shape
% #1 - additional anchors
% #2 - lower y-size of the bipole (from the center).
% #3 - #shape is the name of the shape
% #4 - upper y-size of the bipole (from the center)
% #5 - width of the bipole
% #6 - macros drawing the bipole


\long\def\pgfcircdeclarebipole#1#2#3#4#5#6{
	\pgfdeclareshape{#3shape}{
	
	\savedanchor{\northeast}{
		\pgf@y=#4\pgf@circ@Rlen
		\pgf@y=.5\pgf@y
		\pgf@x=#5\pgf@circ@Rlen
		\pgf@x=.5\pgf@x
	}
	\savedanchor{\northeastborder}{
		\pgf@y=#4\pgf@circ@Rlen
		\pgf@y=.5\pgf@y
		\pgf@y=\ctikzvalof{bipoles/border margin}\pgf@y
		\pgf@x=#5\pgf@circ@Rlen
		\pgf@x=.5\pgf@x
		\pgf@x=\ctikzvalof{bipoles/border margin}\pgf@x
	}
	\savedanchor{\southwestborder}{
		\pgf@y=-#2\pgf@circ@Rlen
		\pgf@y=.5\pgf@y
		\pgf@y=\ctikzvalof{bipoles/border margin}\pgf@y
		\pgf@x=-#5\pgf@circ@Rlen
		\pgf@x=.5\pgf@x
		\pgf@x=\ctikzvalof{bipoles/border margin}\pgf@x
	}
	\savedanchor{\southwest}{
		\pgf@y=-#2\pgf@circ@Rlen
		\pgf@y=.5\pgf@y
		\pgf@x=-#5\pgf@circ@Rlen
		\pgf@x=.5\pgf@x
	}
	\savedanchor{\centerpoint}{
		\pgf@circ@res@down=-#2\pgf@circ@Rlen
		\pgf@circ@res@up=#4\pgf@circ@Rlen
		\pgfpointorigin
		\pgf@y=\pgf@circ@res@up
		\advance\pgf@y by\pgf@circ@res@down
		\pgf@y=.5\pgf@y
	}
	\anchor{center}{\pgfpointorigin}
	\anchor{n}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@x=0cm
	}
	\anchor{ne}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
	}
	\anchor{nw}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@x=-\pgf@x
	}
	\anchor{e}{%
		\ifpgf@circuit@bipole@reversed\else\southwest\northeast\fi
		\pgf@y=0cm
   }
	\anchor{s}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@x=0cm
   }
	\anchor{se}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@x=-\pgf@x
   }
	\anchor{sw}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
   }
	\anchor{w}{
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@y=0cm
	}
	\anchor{north}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@x=0cm
	}
	\anchor{east}{%
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@y=0cm
   }
	\anchor{south}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@x=0cm
   }
	\anchor{west}{
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@y=0cm
	}
	\anchor{right}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@y=0cm
	}
	\anchor{above}{
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@x=0cm
	}
	\anchor{left}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@y=0cm
   }
	\anchor{below}{%
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@x=0cm                    
   }
	\anchor{a}{%
		\ifpgf@circuit@bipole@reversed\southwest\else\northeast\fi
		\pgf@y=0cm
   }
	\anchor{b} {
		\ifpgf@circuit@bipole@reversed\northeast\else\southwest\fi
		\pgf@y=0cm
	}
	\savedanchor{\textanchor}{%
		\pgf@y=\ht\pgfnodeparttextbox
		\pgf@x=-.5\wd\pgfnodeparttextbox
   }
	\anchor{text}{%
		\textanchor
   }
	\anchorborder{%
		\def\pgf@temp{false}
		\ifpgf@circuit@bipole@reversed\pgf@temp
			\pgf@circ@res@left=-\pgf@x
			\pgf@circ@res@right=-\pgf@y
		\else
			\pgf@circ@res@left=\pgf@x
			\pgf@circ@res@right=\pgf@y
		\fi
		\ifdim\pgf@circ@res@right>0cm
			\pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@right}}{\northeastborder}
		\else
	  		\southwestborder	
	  	\pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@right}}{\pgfpoint{-\pgf@x}{-\pgf@y}}
		\fi
	}
	
	#1
	
	\backgroundpath{	
		\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
		
		\northeast
		\pgf@circ@res@up = \pgf@y 
		\pgf@circ@res@zero = 0cm
		\pgf@circ@res@left = -\pgf@x
		\pgf@circ@res@right = \pgf@x
		\southwest
		\pgf@circ@res@down = \pgf@y

 		\pgfstartlinewidth=\pgflinewidth
		
		#6
			
		\pgfsetlinewidth{\pgfstartlinewidth}
	}
	}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Standard bipole shapes declarations

%% Resistor
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/resistor/height}}{resistor}{\ctikzvalof{bipoles/resistor/height}}{\ctikzvalof{bipoles/resistor/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 12

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgf@circ@res@other = \pgf@circ@res@left
		\advance\pgf@circ@res@other by \pgf@circ@res@step 

		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step 
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by \pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
		\pgfusepath{draw} 
}



%% Variable resistor
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vresistor/height}}{vresistor}{\ctikzvalof{bipoles/vresistor/height}}{\ctikzvalof{bipoles/vresistor/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/vresistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 12
		\def\myfrac{.5}

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

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgf@circ@res@other = \pgf@circ@res@left
		\advance\pgf@circ@res@other by \pgf@circ@res@step 
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step 
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
		\advance\pgf@circ@res@other by 2\pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
		\advance\pgf@circ@res@other by \pgf@circ@res@step
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
		\pgfusepath{draw}
		
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@other}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@other}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
}



%% Capacitor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/capacitor/height}}{capacitor}{\ctikzvalof{bipoles/capacitor/height}}{\ctikzvalof{bipoles/capacitor/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/capacitor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 5

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

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfusepath{draw}
}


%% Polar Capacitor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/pcapacitor/height}}{polarcapacitor}{\ctikzvalof{bipoles/pcapacitor/height}}{\ctikzvalof{bipoles/pcapacitor/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/pcapacitor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 5

		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
				
		\pgfscope
			\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+ \ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@left}{\pgf@circ@res@up}}
			\pgftransformrotate{-90}
			\pgfpathsine{\pgfpoint{\pgf@circ@res@up}{-\ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@left}}
			\pgfpathcosine{\pgfpoint{\pgf@circ@res@up}{\ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@left}}
			\pgfusepath{draw}
		\endpgfscope
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		
}

%% Battery

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/battery/height}}{battery}{\ctikzvalof{bipoles/battery/height}}{\ctikzvalof{bipoles/battery/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/battery/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 6

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

		\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{.5\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{.5\pgf@circ@res@down}}

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

		\pgfusepath{draw}
}



%% cute inductor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cute inductor/height}}{cuteinductor}{\ctikzvalof{bipoles/cute inductor/height}}{\ctikzvalof{bipoles/cute inductor/width}}{
	\pgf@circ@res@step=\ctikzvalof{bipoles/cute inductor/width}\pgf@circ@Rlen
	\divide \pgf@circ@res@step by \ctikzvalof{bipoles/cute inductor/coils}

	\pgfdecorationsegmentamplitude=\ctikzvalof{bipoles/cute inductor/height}\pgf@circ@Rlen
	\pgfdecorationsegmentamplitude=.5\pgfdecorationsegmentamplitude
	\pgfdecorationsegmentlength = \pgf@circ@res@step
	\pgfdecorationsegmentaspect=.6
	
	\pgfdecoration{{coil}{\pgfdecoratedremainingdistance}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\endpgfdecoration
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfusepath{stroke}	
}



%% american inductor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/american inductor/height 2}}{americaninductor}{\ctikzvalof{bipoles/american inductor/height}}{\ctikzvalof{bipoles/american inductor/width}}{
	\pgf@circ@res@step=\ctikzvalof{bipoles/american inductor/width}\pgf@circ@Rlen
	\divide \pgf@circ@res@step by \ctikzvalof{bipoles/american inductor/coils}

	\pgfdecorationsegmentamplitude=\ctikzvalof{bipoles/american inductor/height}\pgf@circ@Rlen
	\pgfdecorationsegmentamplitude=.5\pgfdecorationsegmentamplitude
	\pgfdecorationsegmentlength = 1.9\pgf@circ@res@step
	
	\pgfdecoration{{bumps}{\pgfdecoratedremainingdistance}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\endpgfdecoration
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfusepath{stroke}	
}





%% Independent voltage source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsource/height}}{vsource}{\ctikzvalof{bipoles/vsource/height}}{\ctikzvalof{bipoles/vsource/width}}{

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

	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\pgfusepath{draw}
}


%% Independent voltage source - American style

\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]{$-$}

	\pgfusepath{draw}
}



%% Independent sinusoidal voltage source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourcesin/height}}{vsourcesin}{\ctikzvalof{bipoles/vsourcesin/height}}{\ctikzvalof{bipoles/vsourcesin/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfusepath{draw}		
		
		\pgf@circ@res@up = .5\pgf@circ@res@up
		\pgfscope
			\pgftransformrotate{90}
			\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@up}{0cm}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
		\endpgfscope
}




% contributed by Alistair Kwan
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vsourcesquare/height}}{vsourcesquare}{\ctikzvalof{bipoles/vsourcesquare/height}}{\ctikzvalof{bipoles/vsourcesquare/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfusepath{draw}		
		
		\pgf@circ@res@up = .5\pgf@circ@res@up
		\pgfscope
			\pgftransformrotate{90}
			\pgfpathmoveto{\pgfpoint{-1\pgf@circ@res@up}{0cm}}
			\pgfpathlineto{\pgfpoint{-1\pgf@circ@res@up}{1\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{0\pgf@circ@res@up}{1\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{0\pgf@circ@res@up}{-1\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{1\pgf@circ@res@up}{-1\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{1\pgf@circ@res@up}{0\pgf@circ@res@up}}
			\pgfusepath{draw}
		\endpgfscope
}


%% Independent current source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/isource/height}}{isource}{\ctikzvalof{bipoles/isource/height}}{\ctikzvalof{bipoles/isource/width}}{
	\pgfpointorigin
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
	\pgfusepath{draw}
}




%% Independent current source - American

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/isourceam/height}}{isourceAM}{\ctikzvalof{bipoles/isourceam/height}}{\ctikzvalof{bipoles/isourceam/width}}{
	\pgfpointorigin
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfusepath{draw}

	\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{stroke}}
	\endpgfscope
}




%% Independent sinusoidal current source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/isource/height}}{isourcesin}{\ctikzvalof{bipoles/isource/height}}{\ctikzvalof{bipoles/isource/width}}{
	\pgfpointorigin
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfusepath{draw}
	
		\pgf@circ@res@up = .5\pgf@circ@res@up
		\pgfscope
			\pgftransformrotate{90}
			\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@up}{0cm}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
		\endpgfscope

}


%% Controlled voltage source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsource/height}}{cvsource}{\ctikzvalof{bipoles/cvsource/height}}{\ctikzvalof{bipoles/cvsource/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}}
			\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
			\pgfusepath{draw}		
}




%% Controlled voltage source - American

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourceam/height}}{cvsourceAM}{\ctikzvalof{bipoles/cvsourceam/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}}
			\pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@left]{$+$}
			\pgftext[top,rotate=90,y=\ctikzvalof{bipoles/cvsourceam/margin}\pgf@circ@res@right]{$-$}
			\pgfusepath{draw}		
}


%% Controlled sinusoidal voltage source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourcesin/height}}{cvsourcesin}{\ctikzvalof{bipoles/cvsourcesin/height}}{\ctikzvalof{bipoles/cvsourcesin/width}}{

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

		\pgfscope
			\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}}
			\pgfusepath{draw}		
		\endpgfscope	

		\pgf@circ@res@up = .5\pgf@circ@res@up
		\pgfscope
			\pgftransformrotate{90}
			\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@up}{0cm}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
		\endpgfscope
}



%% Controlled sinusoidal current source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cvsourcesin/height}}{cisourcesin}{\ctikzvalof{bipoles/cvsourcesin/height}}{\ctikzvalof{bipoles/cvsourcesin/width}}{

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

		\pgfscope
			\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}}
			\pgfusepath{draw}		
		\endpgfscope	

		\pgf@circ@res@up = .5\pgf@circ@res@up
		\pgfscope
			\pgftransformrotate{90}
			\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@up}{0cm}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathsine{\pgfpoint{.5\pgf@circ@res@up}{-.5\pgf@circ@res@up}}
			\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
		\endpgfscope
}




%% Controlled current source

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/cisource/height}}{cisource}{\ctikzvalof{bipoles/cisource/height}}{\ctikzvalof{bipoles/cisource/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}}
			\pgfpathmoveto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{\pgf@circ@res@down}}
			\pgfusepath{draw}		
}




%% Controlled current source - American

\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}}
			\pgfusepath{draw}		

	\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
}

%% Black generic diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fulldiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{

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

	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}
}

%% Black Zener diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fullzdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{

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

	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope
}

%% Black Schottky diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fullsdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{.8\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{.8\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope

}

%% Black tunnel diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fulltdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope
}

%% Black light emitting diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fulllediode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}

			\pgfscope
			\pgfsetarrowsend{to}
			\pgfpathmoveto{\pgfpoint{.1\pgf@circ@res@up}{.7\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@up}{\pgf@circ@res@up}}
			\pgfusepath{draw}
			\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@up}{.8\pgf@circ@res@up}}
			\pgfusepath{draw}
			\endpgfscope

}

%% Black photodiode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{fullpdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}

			\pgfscope
			\pgfsetarrowsend{to}
			\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@up}{\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.1\pgf@circ@res@up}{.7\pgf@circ@res@up}}
			\pgfusepath{draw}
			\pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@up}{.8\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
			\endpgfscope
}

%% Black varcap

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/varcap/height}}{fullvarcap}{\ctikzvalof{bipoles/varcap/height}}{\ctikzvalof{bipoles/varcap/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw,fill}
	
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
		
	\endpgfscope
}

%% Empty generic diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptydiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{


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

	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}
}

%% Empty Zener diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptyzdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{

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

	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope
}

%% Empty Schottky diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptysdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{.8\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.2\pgf@circ@res@left}{.8\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope

}

%% Empty tunnel diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptytdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope
}

%% Empty light emitting diode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptylediode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{
		
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}

			\pgfscope
			\pgfsetarrowsend{to}
			\pgfpathmoveto{\pgfpoint{.1\pgf@circ@res@up}{.7\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@up}{\pgf@circ@res@up}}
			\pgfusepath{draw}
			\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@up}{.8\pgf@circ@res@up}}
			\pgfusepath{draw}
			\endpgfscope
}

%% Empty photodiode

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/diode/height}}{emptypdiode}{\ctikzvalof{bipoles/diode/height}}{\ctikzvalof{bipoles/diode/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
		\pgfusepath{draw}

			\pgfscope
			\pgfsetarrowsend{to}
			\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@up}{\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.1\pgf@circ@res@up}{.7\pgf@circ@res@up}}
			\pgfusepath{draw}
			\pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@up}{.8\pgf@circ@res@up}}
			\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@up}{.5\pgf@circ@res@up}}
			\pgfusepath{draw}
			\endpgfscope
}

%% Empty varcap

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/varcap/height}}{emptyvarcap}{\ctikzvalof{bipoles/varcap/height}}{\ctikzvalof{bipoles/varcap/width}}{

	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfscope
		\pgftransformxshift{\pgf@circ@res@left}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{0pt}}
		\pgfusepath{draw}
	
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.8\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfusepath{draw}
		
	\endpgfscope
}

%% Closing SPST

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{cspst}{\ctikzvalof{bipoles/interr/height}}{\ctikzvalof{bipoles/interr/width}}{

			\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		
			\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
			\pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgfpathmoveto{\pgfpoint{.9\pgf@circ@res@left}{.9\pgf@circ@res@up}}
            \pgfpatharc{65}{15}{\pgfkeysvalueof{/tikz/circuitikz/bipoles/interr/width}\pgf@circ@Rlen}
			\pgfsetarrowsend{to}
			\pgfusepath{draw}	

}

%% Opening SPST

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{ospst}{\ctikzvalof{bipoles/interr/height}}{\ctikzvalof{bipoles/interr/width}}{

			\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		
			\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
			\pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgfpathmoveto{\pgfpoint{.3\pgf@circ@res@right}{.1\pgf@circ@res@down}}
            \pgfpatharc{15}{65}{\pgfkeysvalueof{/tikz/circuitikz/bipoles/interr/width}\pgf@circ@Rlen}
			\pgfsetarrowsend{to}
			\pgfusepath{draw}	

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Ammeter

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/ammeter/height}}{ammeter}{\ctikzvalof{bipoles/ammeter/height}}{\ctikzvalof{bipoles/ammeter/width}}{
	\def\pgf@circ@temp{right}
	\ifx\tikz@res@label@pos\pgf@circ@temp
		\pgf@circ@res@step=-1.2\pgf@circ@res@up
	\else
		\def\pgf@circ@temp{below}
		\ifx\tikz@res@label@pos\pgf@circ@temp
			\pgf@circ@res@step=-1.2\pgf@circ@res@up
		\else
			\pgf@circ@res@step=1.2\pgf@circ@res@up
		\fi
	\fi

	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}		
	\pgfpointorigin	\pgf@circ@res@other =  \pgf@x  \advance \pgf@circ@res@other by -\pgf@circ@res@up
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
	\pgfusepath{draw}

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

		\pgfscope
			\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@up}
			\pgfusepath{draw}		
		\endpgfscope	

	\pgfsetlinewidth{\pgfstartlinewidth}

	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.8\pgf@circ@res@down}}
	\pgfusepath{draw}
	\pgfnode{circle}{center}{\textbf{A}}{}{}
	\pgfscope
		\pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
		\pgftransformrotate{45}
		\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
	\endpgfscope
	
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@zero}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\pgfusepath{draw}

	\pgfusepath{stroke}	
}

%% Voltmeter

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/voltmeter/height}}{voltmeter}{\ctikzvalof{bipoles/voltmeter/height}}{\ctikzvalof{bipoles/voltmeter/width}}{
	\def\pgf@circ@temp{right}
	\ifx\tikz@res@label@pos\pgf@circ@temp
		\pgf@circ@res@step=-1.2\pgf@circ@res@up
	\else
		\def\pgf@circ@temp{below}
		\ifx\tikz@res@label@pos\pgf@circ@temp
			\pgf@circ@res@step=-1.2\pgf@circ@res@up
		\else
			\pgf@circ@res@step=1.2\pgf@circ@res@up
		\fi
	\fi

	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}		
	\pgfpointorigin	\pgf@circ@res@other =  \pgf@x  \advance \pgf@circ@res@other by -\pgf@circ@res@up
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
	\pgfusepath{draw}

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

		\pgfscope
			\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@up}
			\pgfusepath{draw}		
		\endpgfscope	

	\pgfsetlinewidth{\pgfstartlinewidth}

	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.8\pgf@circ@res@down}}
	\pgfusepath{draw}
	\pgfnode{circle}{center}{\textbf{V}}{}{}
	\pgfscope
		\pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
		\pgftransformrotate{45}
		\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
	\endpgfscope
	
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@zero}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\pgfusepath{draw}

	\pgfusepath{stroke}	
}

%% Short circuit

\pgfcircdeclarebipole{}{0}{short}{0}{0}{ }

%% Open circuit

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/open/height}}{open}{\ctikzvalof{bipoles/open/height}}{\ctikzvalof{bipoles/open/width}}{

}

%% Generic bipole - used as resistor by some (bleah)

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/generic/height}}{generic}{\ctikzvalof{bipoles/generic/height}}{\ctikzvalof{bipoles/generic/width}}{

		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
					
		\pgfusepath{draw} 
}


%% Generic bipole, filled - used as inductor by some (bleah)

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/fullgeneric/height}}{fullgeneric}{\ctikzvalof{bipoles/fullgeneric/height}}{\ctikzvalof{bipoles/fullgeneric/width}}{

		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
					
		\pgfusepath{fill} 
}


%% Generic asymmetric bipole 

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/ageneric/height}}{ageneric}{\ctikzvalof{bipoles/ageneric/height}}{\ctikzvalof{bipoles/ageneric/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
					
		\pgfusepath{draw} 

			\pgfpathrectanglecorners{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
			\pgfusepath{stroke,fill}		
}



%% Memristor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/memristor/height}}{memristor}{\ctikzvalof{bipoles/memristor/height}}{\ctikzvalof{bipoles/memristor/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{.72*\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{.72*\pgf@circ@res@left}{\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{.35*\pgf@circ@res@left}{\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{.35*\pgf@circ@res@left}{-\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.05*\pgf@circ@res@left}{-\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.05*\pgf@circ@res@left}{\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{.42*\pgf@circ@res@right}{\ctikzvalof{bipoles/memristor/wave height}\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{.42*\pgf@circ@res@right}{0pt}}
		\pgfpathlineto{\pgfpoint{.8*\pgf@circ@res@right}{0pt}}
					
		\pgfusepath{draw} 

			\pgfpathrectanglecorners{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
			\pgfusepath{stroke,fill}		
}




%% Generic empty tunable

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/tgeneric/height}}{tgeneric}{\ctikzvalof{bipoles/tgeneric/height}}{\ctikzvalof{bipoles/tgeneric/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{.5\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		\pgfusepath{draw}
		
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
}

%% Generic full tunable

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/tfullgeneric/height}}{tfullgeneric}{\ctikzvalof{bipoles/tfullgeneric/height}}{\ctikzvalof{bipoles/tfullgeneric/width}}{
		\pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@Rlen
		\divide \pgf@circ@res@step by 14

		\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{.5\pgf@circ@res@down}}
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
		\pgfusepath{draw,fill}
		
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
}


%% Variable Cute Inductor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcuteinductor/height}}{vcuteinductor}{\ctikzvalof{bipoles/vcuteinductor/height}}{\ctikzvalof{bipoles/vcuteinductor/width}}{
	\pgf@circ@res@step=\ctikzvalof{bipoles/vcuteinductor/width}\pgf@circ@Rlen
	\divide \pgf@circ@res@step by \ctikzvalof{bipoles/vcuteinductor/coils}

	\pgfdecorationsegmentamplitude=\ctikzvalof{bipoles/vcuteinductor/coil height}\pgf@circ@Rlen
	\pgfdecorationsegmentamplitude=.5\pgfdecorationsegmentamplitude
	\pgfdecorationsegmentlength = \pgf@circ@res@step
	\pgfdecorationsegmentaspect=.6
	
	\pgfdecoration{{coil}{\pgfdecoratedremainingdistance}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\endpgfdecoration
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfusepath{stroke}	
	
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
}


%% variable american inductor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vamerican inductor/height 2}}{vamericaninductor}{\ctikzvalof{bipoles/vamerican inductor/height}}{\ctikzvalof{bipoles/vamerican inductor/width}}{
	\pgf@circ@res@step=\ctikzvalof{bipoles/vamerican inductor/width}\pgf@circ@Rlen
	\divide \pgf@circ@res@step by \ctikzvalof{bipoles/vamerican inductor/coils}

	\pgfdecorationsegmentamplitude=\ctikzvalof{bipoles/vamerican inductor/height}\pgf@circ@Rlen
	\pgfdecorationsegmentamplitude=.5\pgfdecorationsegmentamplitude
	\pgfdecorationsegmentamplitude=.5\pgfdecorationsegmentamplitude % per freccia
	\pgfdecorationsegmentlength = 1.9\pgf@circ@res@step
	
	\pgfdecoration{{bumps}{\pgfdecoratedremainingdistance}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
	\endpgfdecoration
		\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfusepath{stroke}	
	
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
}




%% Variable Capacitor

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcapacitor/height}}{vcapacitor}{\ctikzvalof{bipoles/vcapacitor/height}}{\ctikzvalof{bipoles/vcapacitor/width}}{
		%\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/width}\pgf@circ@Rlen
		\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/capacitor width} \pgf@circ@res@right

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

		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		
		\pgfscope
		\pgfsetarrowsend{to}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
		\pgfusepath{draw}
		\endpgfscope
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{0pt}}
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfsetlinewidth{\pgfstartlinewidth}
		\pgfusepath{draw}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Handling of terminals


%% Easily usable styles

\ctikzset{*-/.style =  {\circuitikzbasekey/bipole/nodes/left=full, \circuitikzbasekey/bipole/nodes/right=none}}
\ctikzset{*-o/.style = {\circuitikzbasekey/bipole/nodes/left=full, \circuitikzbasekey/bipole/nodes/right=empty}}
\ctikzset{*-*/.style = {\circuitikzbasekey/bipole/nodes/left=full, \circuitikzbasekey/bipole/nodes/right=full}}
\ctikzset{o-/.style = {\circuitikzbasekey/bipole/nodes/left=empty, \circuitikzbasekey/bipole/nodes/right=none}}
\ctikzset{o-o/.style = {\circuitikzbasekey/bipole/nodes/left=empty, \circuitikzbasekey/bipole/nodes/right=empty}}
\ctikzset{o-*/.style = {\circuitikzbasekey/bipole/nodes/left=empty, \circuitikzbasekey/bipole/nodes/right=full}}
\ctikzset{-o/.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=empty}}
\ctikzset{-*/.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=full}}

\tikzset{reversed/.style = {\circuitikzbasekey/bipole/reversed=true}}


%% The output routine

\def\drawpoles{
	\pgfextra{ \edef\pgf@circ@temp{\ctikzvalof{bipole/nodes/left}} \def\pgf@temp{empty}  }
	\ifx\pgf@temp\pgf@circ@temp 
		{ (\tikztostart) node[ocirc] {} }
	\else 
		\pgfextra{ \def\pgf@temp{full}  }
		\ifx\pgf@temp\pgf@circ@temp
			{ (\tikztostart) node[circ] {} }
		\fi
	\fi
	\pgfextra{ \edef\pgf@circ@temp{\ctikzvalof{bipole/nodes/right}} \def\pgf@temp{empty}  }
	\ifx\pgf@temp\pgf@circ@temp
		{ (\tikztotarget) node[ocirc] {} }
	\else
		\pgfextra{ \def\pgf@temp{full}  }
		\ifx\pgf@temp\pgf@circ@temp
			{ (\tikztotarget) node[circ] {} }
		\fi
	\fi 
}




















%% Lamp

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/lamp/height}}{lamp}{\ctikzvalof{bipoles/lamp/height}}{\ctikzvalof{bipoles/lamp/width}}{

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

	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfpathmoveto{\pgfpoint{.7071*\pgf@circ@res@left}{.7071*\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{.7071*\pgf@circ@res@right}{.7071*\pgf@circ@res@down}}
	\pgfpathmoveto{\pgfpoint{.7071*\pgf@circ@res@left}{.7071*\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{.7071*\pgf@circ@res@right}{.7071*\pgf@circ@res@up}}
	\pgfusepath{draw}
}

% Contributed by Leonardo Azzinnari

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/tline/height}
                        }{tline}{\ctikzvalof{bipoles/tline/height}
                                 }{\ctikzvalof{bipoles/tline/width}
                                   }{\pgf@circ@res@step=\ctikzvalof{bipoles/tline/width} \pgf@circ@Rlen
                                     \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
                                     \pgfpathellipse{\pgfpoint{0.5\pgf@circ@res@step}{0\pgf@circ@res@step}
                                                     }{\pgfpoint{0.125\pgf@circ@res@step}{0\pgf@circ@res@step}
                                                       }{\pgfpoint{0\pgf@circ@res@step}{0.25\pgf@circ@res@step}}
                                     \pgfpathmoveto{\pgfpoint{0.5\pgf@circ@res@step}{0.25\pgf@circ@res@step}}
                                     \pgfpathlineto{\pgfpoint{-0.5\pgf@circ@res@step+0.125\pgf@circ@res@step}{0.25\pgf@circ@res@step}}
                                     \pgfpatharc{-90}{90}{-0.125\pgf@circ@res@step and -0.25\pgf@circ@res@step}
                                     \pgfpathlineto{\pgfpoint{0.5\pgf@circ@res@step}{-0.25\pgf@circ@res@step}}
                                     \pgfusepath{draw}
                                     }




%% SQUID added by Cor Molenaar 5 March 2010

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/squid/height}}{squid}{\ctikzvalof{bipoles/squid/height}}{\ctikzvalof{bipoles/squid/width}}{

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

	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{1.35*\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{0.65*\pgf@circ@res@up}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{0.65*\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{1.35*\pgf@circ@res@up}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{1.35*\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{0.65*\pgf@circ@res@down}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{0.65*\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{1.35*\pgf@circ@res@down}}

	\pgfusepath{draw}
}



% Generic barrier added by Cor Molenaar 5 March 2010

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/barrier/height}}{barrier}{\ctikzvalof{bipoles/barrier/height}}{\ctikzvalof{bipoles/barrier/width}}{

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

	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@step}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@step}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{0.35*\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{0.35*\pgf@circ@res@down}}
	\pgfpathmoveto{\pgfpoint{0.35*\pgf@circ@res@left}{0.35*\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{0.35*\pgf@circ@res@right}{0.35*\pgf@circ@res@up}}

	\pgfusepath{draw}
}


% Contributed by Danilo Piazzalunga
 
\pgfdeclareshape{buffer}
	{
	  \anchor{center}{\pgfpointorigin}
	  \savedanchor\northwest{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/bipoles/buffer/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/bipoles/buffer/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }
	  \anchor{south}{
		\northwest
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\left{%
	  	\pgf@y=0pt
	  }
	  \anchor{in}{
		\northwest
		\pgf@y=0pt
	  }
	  \anchor{out}{
		\northwest
		\pgf@y=0pt
		\pgf@x=-\pgf@x
	  }
	  
	  \backgroundpath{			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
			
			
			\northwest
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@down = -\pgf@y
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
			
	\pgfscope
		\pgfsetlinewidth{2\pgflinewidth}
		\pgftransformxshift{.7\pgf@circ@res@left}
		\pgf@circ@res@step=\pgf@circ@res@right
		\advance\pgf@circ@res@step by -\pgf@circ@res@left
		\pgf@circ@res@step=.7\pgf@circ@res@step
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
		\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@left}{0pt}}
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
		\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
	
		\pgfusepath{draw}
	  
	  }
	}





\pgfdeclareshape{plain amp}
	{
	  \anchor{center}{\pgfpointorigin}
	  \savedanchor\northwest{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }
	  \anchor{south}{
		\northwest
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\left{%
	  	\pgf@y=0pt
	  }
	  \savedanchor\inOne{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/input height}\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }	  
	  \anchor{-}{
		\inOne
	  }
	  \anchor{+}{
		\inOne
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\up{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/width}\pgf@x
		\pgf@x=.5\pgf@x
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
	    \pgfpointlineattime{
			\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/up pos}}{
			\pgfpoint{
				\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/port width}\pgf@circ@res@left}
				{\pgf@circ@res@up}}
			{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
	  }
	  \anchor{up}{
		\up
	  }
	  \anchor{down}{
		\up
		\pgf@y=-\pgf@y
	  }
	  \anchor{out}{
		\northwest
		\pgf@y=0pt
		\pgf@x=-\pgf@x
	  }
	  
	  \backgroundpath{			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
			
			
			\northwest
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@down = -\pgf@y
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
			
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/input height}\pgf@circ@res@up}}
	

	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/plain amp/input height}\pgf@circ@res@down}}
		
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
	
	\pgfusepath{draw}

						
	\pgfscope
		\pgfsetlinewidth{2\pgflinewidth}
		\pgftransformxshift{.7\pgf@circ@res@left}
		\pgf@circ@res@step=\pgf@circ@res@right
		\advance\pgf@circ@res@step by -\pgf@circ@res@left
		\pgf@circ@res@step=.7\pgf@circ@res@step
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		
		
	  
	  }
	}

\endinput
