% Copyright 2018-2024 by Romano Giannetti
% Copyright 2015-2024 by Stefan Lindner
% Copyright 2013-2024 by Stefan Erhardt
% Copyright 2007-2024 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 files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Standard bipole shapes declarations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Generic macro and flags for bipoles %<<<
% Fixing tunable directions
\newif\ifpgf@circ@fixtunable@dir
\ctikzset{bipoles/fix tunable direction/.is if=pgf@circ@fixtunable@dir}
\ctikzset{bipoles/fix tunable direction=true}
% choosing several arrows
\pgf@circ@declare@family@arrows{tunable}
\pgf@circ@declare@family@arrows{wiper}
\pgf@circ@declare@family@arrows{switch}
\pgf@circ@declare@family@arrows{gto gate}
\pgf@circ@declare@family@arrows{opto}

%>>>


%%%%%%%%%%%%%%%%%%%%%%%%
% Resistive components: generics, resistors, wires
%%%%%%%%%%%%%%%%%%%%%%%%

%% Definitions for resistive components %<<<

% Zig Zag resistors
\ctikzset{resistors/zigs/.initial=3}
\ctikzset{resistors/width/.code={%
    \ctikzset{bipoles/resistor/width=#1}%
    \ctikzset{bipoles/vresistor/width=#1}%
    \ctikzset{bipoles/potentiometer/width=#1}%
    \ctikzset{bipoles/resistivesens/width=#1}%
    \ctikzset{bipoles/photoresistor/width=#1}%
    \ctikzset{bipoles/thermistor/width=#1}%
    \ctikzset{bipoles/thermistorntc/width=#1}%
    \ctikzset{bipoles/thermistorptc/width=#1}%
    \ctikzset{bipoles/varistor/width=#1}%
    \ctikzset{bipoles/generic/width=#1}%
    \ctikzset{bipoles/generic potentiometer/width=#1}%
    \ctikzset{bipoles/ageneric/width=#1}%
    \ctikzset{bipoles/tgeneric/width=#1}%
    \ctikzset{bipoles/ldresistor/width=#1}%
    \ctikzset{bipoles/ldgeneric/width=#1}%
}}
\ctikzset{wiper pos/.code={%
    \ctikzset{bipoles/potentiometer/wiper pos=#1}%
    \ctikzset{bipoles/generic potentiometer/wiper pos=#1}%
}}
% zigzag resistor
\ctikzset{bipoles/resistor/height/.initial=.3}
\ctikzset{bipoles/resistor/width/.initial=.8}
\ctikzset{bipoles/potentiometer/height/.initial=.8}
\ctikzset{bipoles/potentiometer/height 2/.initial=.3}
\ctikzset{bipoles/potentiometer/width/.initial=.8}
\ctikzset{bipoles/potentiometer/wiper pos/.initial=.5}
\ctikzset{bipoles/vresistor/height/.initial=.6}
\ctikzset{bipoles/vresistor/width/.initial=.8}
\ctikzset{bipoles/resistivesens/height/.initial=.6}
\ctikzset{bipoles/resistivesens/width/.initial=.8}
\ctikzset{bipoles/ldresistor/height/.initial=.8}
\ctikzset{bipoles/ldresistor/width/.initial=.8}
\ctikzset{bipoles/ldresistor/internal scale/.initial=.8}
% square resistors
\ctikzset{bipoles/photoresistor/height/.initial=.6}
\ctikzset{bipoles/photoresistor/height 2/.initial=.3}
\ctikzset{bipoles/photoresistor/width/.initial=.8}
\ctikzset{bipoles/thermistor/main/.initial=.7}
\ctikzset{bipoles/thermistor/height/.initial=.428}%.3/.7
\ctikzset{bipoles/thermistorntc/width/.initial=.8}
\ctikzset{bipoles/thermistorntc/main/.initial=.7}
\ctikzset{bipoles/thermistorntc/height/.initial=.428}%.3/.7
\ctikzset{bipoles/thermistorntc/height 2/.initial=.75}%.3/.7
\ctikzset{bipoles/thermistorptc/width/.initial=.8}
\ctikzset{bipoles/thermistorptc/main/.initial=.7}
\ctikzset{bipoles/thermistorptc/height/.initial=.428}%.3/.7
\ctikzset{bipoles/thermistorptc/height 2/.initial=.75}%.3/.7
\ctikzset{bipoles/thermistor/width/.initial=.8}
\ctikzset{bipoles/varistor/main/.initial=.7}
\ctikzset{bipoles/varistor/height/.initial=.428}%.3/.7
\ctikzset{bipoles/varistor/width/.initial=.8}
\ctikzset{bipoles/generic/height/.initial=.30}
\ctikzset{bipoles/generic/width/.initial=.80}
\ctikzset{bipoles/generic potentiometer/height/.initial=.80}
\ctikzset{bipoles/generic potentiometer/height 2/.initial=.30}
\ctikzset{bipoles/generic potentiometer/width/.initial=.80}
\ctikzset{bipoles/generic potentiometer/wiper pos/.initial=.5}
\ctikzset{bipoles/ageneric/height/.initial=.30}
\ctikzset{bipoles/tgeneric/height/.initial=.70}
\ctikzset{bipoles/tgeneric/width/.initial=.80}
\ctikzset{bipoles/ageneric/width/.initial=.80}
\ctikzset{bipoles/memristor/height/.initial=.30}
\ctikzset{bipoles/memristor/wave height/.initial=.5}
\ctikzset{bipoles/memristor/width/.initial=.80}
\ctikzset{bipoles/ldgeneric/height/.initial=.8}
\ctikzset{bipoles/ldgeneric/width/.initial=.8}
\ctikzset{bipoles/ldgeneric/internal scale/.initial=.8}

\newif\ifpgf@circuit@europeanresistor
\ctikzset{resistor/.is choice}
\ctikzset{resistor/american/.code = \pgf@circuit@europeanresistorfalse }
\ctikzset{resistor/european/.code = \pgf@circuit@europeanresistortrue }
\tikzset{american resistors/.style = {\circuitikzbasekey/resistor = american}}
\tikzset{european resistors/.style = {\circuitikzbasekey/resistor = european}}%

% wires (open, shorts, ...)

\ctikzset{bipoles/open/height/.initial=.3} %necessary for curly voltages
\ctikzset{bipoles/open/width/.initial=.3} %necessary for curly voltages
\ctikzset{bipoles/open/voltage/straight label distance/.initial=0}
\ctikzset{bipoles/open/voltage/distance from node/.initial=.2}
\ctikzset{bipoles/short/height/.initial=.1} %dummy height for voltage positioning
\ctikzset{bipoles/short/width/.initial=.1} %dummy width for voltage positioning
% multiwire
\ctikzset{bipoles/multiwire/height/.initial=0.4}
\ctikzset{bipoles/multiwire/width/.initial=0.2}
\ctikzset{bipoles/multiwire/spacing/.initial=0.05}
% crossing wires
\ctikzset{bipoles/crossing/size/.initial=.2}

%%>>>

%% Shapes for generic, resistives and wires components %<<<
%% Short circuit

%%% NOTICE that the short is really NOT drawn; we trust the fact that its
%%% natural length is zero.
\pgfcircdeclarebipole
{% fix the anchor border to add a bit of space for voltage and labels
    % it uses the dummy width and height
    \anchorborder{%
        \ifpgf@circuit@bipole@inverted
            \pgf@circ@res@left=-\pgf@x
            \pgf@circ@res@up=-\pgf@y
        \else
            \pgf@circ@res@left=\pgf@x
            \pgf@circ@res@up=\pgf@y
        \fi
        \ifdim\pgf@circ@res@up>0cm
            \pgf@x=\ctikzvalof{bipoles/short/width}\pgf@circ@Rlen
            \pgf@y=\ctikzvalof{bipoles/short/height}\pgf@circ@Rlen
            \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            {\pgfpoint{\pgf@x}{\pgf@y}}
        \else
            \pgf@x=-\ctikzvalof{bipoles/short/width}\pgf@circ@Rlen
            \pgf@y=-\ctikzvalof{bipoles/short/height}\pgf@circ@Rlen
            \pgfpointborderrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            {\pgfpoint{-\pgf@x}{-\pgf@y}}
        \fi
    }
}
{0}
{short}
{0}
{0}
{}

%% Open circuit
\pgfcircdeclarebipole
{}
{\ctikzvalof{bipoles/open/height}}
{open}
{\ctikzvalof{bipoles/open/height}}
{\ctikzvalof{bipoles/open/width}}
{}

% multiwire(s)
\pgfcircdeclarebipole
{}
{\ctikzvalof{bipoles/multiwire/height}}
{multiwire}
{\ctikzvalof{bipoles/multiwire/height}}
{\ctikzvalof{bipoles/multiwire/width}}
{
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}

\pgfcircdeclarebipole
{}
{\ctikzvalof{bipoles/multiwire/height}}
{bmultiwire}
{\ctikzvalof{bipoles/multiwire/height}}
{\ctikzvalof{bipoles/multiwire/width}}
{
    \pgf@circ@res@other=\ctikzvalof{bipoles/multiwire/spacing}\pgf@circ@Rlen
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@other}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}

\pgfcircdeclarebipole
{}
{\ctikzvalof{bipoles/multiwire/height}}
{tmultiwire}
{\ctikzvalof{bipoles/multiwire/height}}
{\ctikzvalof{bipoles/multiwire/width}}
{
    \pgf@circ@res@other=\ctikzvalof{bipoles/multiwire/spacing}\pgf@circ@Rlen
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@other}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+2\pgf@circ@res@other}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{2\pgf@circ@res@other}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}

%%%%%%%%%%%%%%%%
%% Crossing
%%%%%%%%%%%%%%%%

%% crossing bipole (but see also nodes)
\pgfcircdeclarebipole
{}
{\ctikzvalof{bipoles/crossing/size}}
{crossing}
{\ctikzvalof{bipoles/crossing/size}}
{\ctikzvalof{bipoles/crossing/size}}{
    \pgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgfpathlineto{\pgfpoint{0.4\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgfpatharc{0}{-180}{0.4*\pgf@circ@res@left}
        \pgfsetbeveljoin
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfusepath{draw}
    \endpgfscope
}
%
%
%% Generic bipole - used as resistor by some
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/generic/height}}
{generic}
{\ctikzvalof{bipoles/generic/height}}
{\ctikzvalof{bipoles/generic/width}}
{
    % \pgf@circ@debug@colors
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
}

%
% generic crossed, suggested by Radványi Patrik Tamás <patrikradvanyi@gmail.com>
% inherit "generic" properties
%
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/generic/height}}
{xgeneric}
{\ctikzvalof{bipoles/generic/height}}
{\ctikzvalof{bipoles/generic/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
    % cross it
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfusepath{draw}
}
%% Generic empty tunable
\pgfcircdeclarebipolescaled{resistors}
{
    \anchor{wiper}{\northeast\pgf@x=-0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{W}{\northeast\pgf@x=-0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.5\pgf@x}
}
{\ctikzvalof{bipoles/tgeneric/height}}
{tgeneric}
{\ctikzvalof{bipoles/tgeneric/height}}
{\ctikzvalof{bipoles/tgeneric/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{.4\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{.4\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \ifpgf@circ@fixtunable@dir
            \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@up}}
        \else
            \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}}
        \fi
        \pgfusepath{draw}
    \endpgfscope
}

%% Generic asymmetric bipole
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/ageneric/height}}
{ageneric}
{\ctikzvalof{bipoles/ageneric/height}}
{\ctikzvalof{bipoles/ageneric/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope

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

%% Memristor
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/memristor/height}}
{memristor}
{\ctikzvalof{bipoles/memristor/height}}
{\ctikzvalof{bipoles/memristor/width}}
{
    \pgf@circ@res@step = \ctikzvalof{bipoles/resistor/width}\pgf@circ@scaled@Rlen
    \divide \pgf@circ@res@step by 14

    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope
    \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}
}

%% Photoresistor
\pgfcircdeclarebipolescaled{resistors}
{% anchor for light arrows
    \anchor{arrows}{\northeast\pgf@x=0.575\pgf@x\pgf@y=1.1\pgf@y}%
}
{\ctikzvalof{bipoles/photoresistor/height 2}}
{photoresistor}
{\ctikzvalof{bipoles/photoresistor/height}}
{\ctikzvalof{bipoles/photoresistor/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope

    \pgfscope
        \pgf@circ@set@optoarrow@style
        \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.3\pgf@circ@res@right}{-1.2\pgf@circ@res@down}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{.45\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.05\pgf@circ@res@right}{-1.2\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}



%% Thermistor
\pgfcircdeclarebipolescaled{resistors}
{% anchor for labelling the type of dependency
    \anchor{label}{%
        \southwest
        \pgf@x=0.4\pgf@x
        \pgf@y=1.2\pgf@y
    }%
    \pgfcirc@border@extend@updown{1}{1.2}
    \anchor{wiper}{\northeast\pgf@x=-\pgf@x\pgf@y=-1.2\pgf@y}
    \anchor{W}{\northeast\pgf@x=-\pgf@x\pgf@y=-1.2\pgf@y}
    \anchor{tip}{\northeast}
}
{\ctikzvalof{bipoles/thermistor/height}}
{thermistor}
{\ctikzvalof{bipoles/thermistor/height}}
{\ctikzvalof{bipoles/thermistor/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\ctikzvalof{bipoles/thermistor/main}\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{-\ctikzvalof{bipoles/thermistor/main}\pgf@circ@res@up}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
    \pgf@circ@set@relative@thickness{modifier thickness}
    \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{-\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{1.2\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{1.2\pgf@circ@res@down}}
    \pgfusepath{draw}
}

%% Thermistor PTC
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/thermistorptc/height 2}}
{thermistorptc}
{\ctikzvalof{bipoles/thermistorptc/height}}
{\ctikzvalof{bipoles/thermistorptc/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\ctikzvalof{bipoles/thermistorptc/main}\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{-\ctikzvalof{bipoles/thermistorptc/main}\pgf@circ@res@up}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{-\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope

    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfsetarrowsend{latexslim}
    \pgfpathmoveto{\pgfpoint{.62\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{.62\pgf@circ@res@left}{.7\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgfpathmoveto{\pgfpoint{.45\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{.45\pgf@circ@res@left}{.7\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgf@circ@text@strokecolor
    \pgftext[top,x=.85\pgf@circ@res@left,y=.75\pgf@circ@res@down]{\pgf@circ@font@tiny$\vartheta$}
}

%% Thermistor NTC
\pgfcircdeclarebipolescaled{resistors}
{}
{\ctikzvalof{bipoles/thermistorntc/height 2}}
{thermistorntc}
{\ctikzvalof{bipoles/thermistorntc/height}}
{\ctikzvalof{bipoles/thermistorntc/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\ctikzvalof{bipoles/thermistorntc/main}\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{-\ctikzvalof{bipoles/thermistorntc/main}\pgf@circ@res@up}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{-\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope

    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfsetarrowsend{latexslim}
    \pgfpathmoveto{\pgfpoint{.62\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{.62\pgf@circ@res@left}{.7\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgfpathmoveto{\pgfpoint{.45\pgf@circ@res@left}{.7\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{.45\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgf@circ@text@strokecolor
    \pgftext[top,x=.85\pgf@circ@res@left,y=.75\pgf@circ@res@down]{\pgf@circ@font@tiny$\vartheta$}
}

%% Varistor
\pgfcircdeclarebipolescaled{resistors}
{
    \pgfcirc@border@extend@updown{1}{1.4}
}
{\ctikzvalof{bipoles/varistor/height}}
{varistor}
{\ctikzvalof{bipoles/varistor/height}}
{\ctikzvalof{bipoles/varistor/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\ctikzvalof{bipoles/varistor/main}\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{-\ctikzvalof{bipoles/varistor/main}\pgf@circ@res@up}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{-\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
    \pgf@circ@text@strokecolor
    \pgftext[top,x=.65\pgf@circ@res@left,y=1.2\pgf@circ@res@down]{{\pgf@circ@font@tiny\textsf{U}}}
}
%% MOV
\pgfcircdeclarebipolescaled{resistors}
{
    \pgfcirc@border@extend@updown{1.2}{1.2}
}
{\ctikzvalof{bipoles/varistor/height}}
{mov}
{\ctikzvalof{bipoles/varistor/height}}
{\ctikzvalof{bipoles/varistor/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\ctikzvalof{bipoles/varistor/main}\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{-\ctikzvalof{bipoles/varistor/main}\pgf@circ@res@up}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{-1.1\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-0.7\pgf@circ@res@left}{-1.1\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{0.7\pgf@circ@res@left}{1.1\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{1.1\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}
%% Generic tunable
\pgfcircdeclarebipolescaled{resistors}
{
    \savedanchor{\wiper}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@ya=\ctikzvalof{bipoles/generic potentiometer/height}\pgf@circ@scaled@Rlen
            \pgf@y=.5\pgf@ya
            \pgf@xa=\ctikzvalof{bipoles/generic potentiometer/width}\pgf@circ@scaled@Rlen
            \pgfmathsetlength{\pgf@x}{(\ctikzvalof{bipoles/generic potentiometer/wiper pos}-0.5)*\pgf@xa}
        }
    \anchor{wiper}{\wiper}
    \anchor{W}{\wiper}
    \anchor{tip}{\wiper\pgf@xa=\pgf@x\southwest\pgf@x=\pgf@xa\pgf@y=-\pgf@y}
}
{\ctikzvalof{bipoles/generic potentiometer/height 2}}
{genericpotentiometer}
{\ctikzvalof{bipoles/generic potentiometer/height}}
{\ctikzvalof{bipoles/generic potentiometer/width}}
{

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

    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope
    \pgfscope
        %\pgfsetlinewidth{\pgfstartlinewidth}
        \pgfcirc@set@arrows{wiper}{}{latexslim}
        \pgfextractx{\pgf@circ@res@other}{\wiper}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% european style LDR
\pgfcircdeclarebipolescaled{resistors}
{% anchor for light arrows
    \anchor{arrows}{\northeast\pgf@x=1.6\pgf@x\pgf@y=1.4\pgf@y}%
    \savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
}
{\ctikzvalof{bipoles/ldgeneric/height}}
{ldgeneric}
{\ctikzvalof{bipoles/ldgeneric/height}}
{\ctikzvalof{bipoles/ldgeneric/width}}
{%
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@draworfill
    \endpgfscope
    \pgfscope
        % arrows
        \pgf@circ@set@optoarrow@style
        \pgfpathmoveto{\pgfpoint{1.4\pgf@circ@res@right}{1.4\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.8\pgf@circ@res@right}{0.8\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{1.6\pgf@circ@res@right}{1.2\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{1.0\pgf@circ@res@right}{0.6\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
    \edef\@@intscale{\ctikzvalof{bipoles/ldgeneric/internal scale}}%
    \pgfmathsetmacro{\@@hscale}{0.5*\@@intscale}%
    \pgftransformscale{\@@intscale}% the end of the bipole will deactivate it
    % the generic will be reduced by @@intscale; let's undo the scaling to
    % connect the leads to the end of the component.
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left/\@@intscale-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right/\@@intscale+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/ldgeneric/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgfusepath{draw}
    \pgfscope
        % reset the up at the "generic" thing
        \pgf@circ@res@up=\ctikzvalof{bipoles/generic/height}\pgf@circ@scaled@Rlen
        \pgf@circ@res@up=0.5\pgf@circ@res@up
        \pgf@circ@res@down=-\pgf@circ@res@up
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfusepath{draw}
    \endpgfscope
}%

%% Zig-zag resistors
\def\pgf@circ@zigzag#1{%
    \divide \pgf@circ@res@step by \numexpr4*\zigs\relax

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{\pgf@circ@res@zero}}
    \pgf@circ@res@other = \pgf@circ@res@left
    \pgf@circ@count@a=\zigs\relax
    % first half zig
    \advance\pgf@circ@res@other by \pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-#1\pgf@circ@res@down}}
    \pgfmathloop%
    \advance\pgf@circ@count@a by -1\relax% Loop zigs -1 times
    \ifnum\pgf@circ@count@a>0
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{#1\pgf@circ@res@down}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-#1\pgf@circ@res@down}}
    \repeatpgfmathloop%
    % last zig and a half
    \advance\pgf@circ@res@other by 2\pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{#1\pgf@circ@res@down}}
    \advance\pgf@circ@res@other by \pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
    \pgfsetbeveljoin
    \pgfusepath{draw}
}

%% Resistor
\pgfcircdeclarebipolescaled{resistors}
{
\savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
}
{\ctikzvalof{bipoles/resistor/height}}
{resistor}
{\ctikzvalof{bipoles/resistor/height}}
{\ctikzvalof{bipoles/resistor/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/resistor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgf@circ@zigzag{1}
}


%% Variable resistor
\pgfcircdeclarebipolescaled{resistors}
{
\savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
\anchor{wiper}{\northeast\pgf@x=-0.4\pgf@x\pgf@y=-\pgf@y}
\anchor{W}{\northeast\pgf@x=-0.4\pgf@x\pgf@y=-\pgf@y}
\anchor{tip}{\northeast\pgf@x=0.4\pgf@x}
}
{\ctikzvalof{bipoles/vresistor/height}}
{vresistor}
{\ctikzvalof{bipoles/vresistor/height}}
{\ctikzvalof{bipoles/vresistor/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/vresistor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgf@circ@zigzag{.5}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \ifpgf@circ@fixtunable@dir
            \pgfpathmoveto{\pgfpoint{-.4\pgf@circ@res@right}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \else
            \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@right}{\pgf@circ@res@down}}
        \fi
        \pgfusepath{draw}
    \endpgfscope
}

%% Potentiometer
\pgfcircdeclarebipolescaled{resistors}
{
    \savedanchor{\wiper}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@ya=\ctikzvalof{bipoles/potentiometer/height}\pgf@circ@scaled@Rlen
            \pgf@y=.5\pgf@ya
            \pgf@xa=\ctikzvalof{bipoles/potentiometer/width}\pgf@circ@scaled@Rlen
            \pgfmathsetlength{\pgf@x}{(\ctikzvalof{bipoles/potentiometer/wiper pos}-0.5)*\pgf@xa}
        }
    \anchor{wiper}{\wiper}
    \anchor{W}{\wiper}
    \savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
    \anchor{tip}{\wiper\pgf@xa=\pgf@x\southwest\pgf@x=\pgf@xa\pgf@y=-\pgf@y}
}
{\ctikzvalof{bipoles/potentiometer/height 2}}
{potentiometer}
{\ctikzvalof{bipoles/potentiometer/height}}
{\ctikzvalof{bipoles/potentiometer/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/potentiometer/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgf@circ@zigzag{1}

    \pgfscope
        %\pgfsetlinewidth{\pgfstartlinewidth}
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{wiper}{}{latexslim}
        \pgfextractx{\pgf@circ@res@other}{\wiper}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Resistive sensor
\pgfcircdeclarebipolescaled{resistors}
{% anchor for labelling the type of dependency
    \anchor{label}{\southwest\pgf@x=0.4\pgf@x}%
    \savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
    \anchor{wiper}{\northeast\pgf@x=-0.9\pgf@x\pgf@y=-\pgf@y}
    \anchor{W}{\northeast\pgf@x=-0.9\pgf@x\pgf@y=-\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.4\pgf@x}
}
{\ctikzvalof{bipoles/resistivesens/height}}
{resistivesens}
{\ctikzvalof{bipoles/resistivesens/height}}
{\ctikzvalof{bipoles/resistivesens/width}}
{%
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/resistivesens/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgf@circ@zigzag{.5}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-.9\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}%

%% american style LDR
\pgfcircdeclarebipolescaled{resistors}
{% anchor for light arrows
    \anchor{arrows}{\northeast\pgf@x=1.6\pgf@x\pgf@y=1.4\pgf@y}%
    \savedmacro{\zigs}{\edef\zigs{\ctikzvalof{resistors/zigs}}}
    % \pgfcirc@border@extend@full{1.2}{1.2}{1.2}{1.2}
}
{\ctikzvalof{bipoles/ldresistor/height}}
{ldresistor}
{\ctikzvalof{bipoles/ldresistor/height}}
{\ctikzvalof{bipoles/ldresistor/width}}
{%
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@draworfill
    \endpgfscope
    \pgfscope
        % arrows
        \pgf@circ@set@optoarrow@style
        \pgfpathmoveto{\pgfpoint{1.4\pgf@circ@res@right}{1.4\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.8\pgf@circ@res@right}{0.8\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{1.6\pgf@circ@res@right}{1.2\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{1.0\pgf@circ@res@right}{0.6\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
    \edef\@@intscale{\ctikzvalof{bipoles/ldresistor/internal scale}}%
    \pgfmathsetmacro{\@@hscale}{0.5*\@@intscale}%
    \pgftransformscale{\@@intscale}% the end of the bipole will deactivate it
    % the zigzag will be reduced by @@intscale; let's undo the scaling to
    % connect the leads to the end of the component.
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left/\@@intscale-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right/\@@intscale+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{+0pt}}
    \pgftransformationadjustments
    \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{bipoles/ldresistor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}
    \pgf@circ@zigzag{\@@hscale}
}%


%>>>

%% Paths for resistive components: generic, resistors and wires% %<<<

%% GENERICS
\def\pgf@circ@empty@path#1{}
\pgfcirc@activate@bipole@simple{l}{generic}
\pgfcirc@activate@bipole@simple{l}{ageneric}
\pgfcirc@activate@bipole@simple{l}{tgeneric}
\pgfcirc@activate@bipole@simple{l}{xgeneric}
\pgfcirc@activate@bipole@simple{l}{fullgeneric}
\pgfcirc@activate@bipole@simple{l}{tfullgeneric}
\pgfcirc@activate@bipole@simple{l}{short}
\pgfcirc@activate@bipole@simple{l}{open}

%% wires and crossings

\pgfcirc@activate@bipole@simple{l}{crossing}
\pgfcirc@style@to@style{crossing}{xing}
\pgfcirc@activate@bipole@simple{l}{multiwire}
\pgfcirc@activate@bipole@simple{l}{bmultiwire}
\pgfcirc@activate@bipole@simple{l}{tmultiwire}

% automatically switching path --- to be defined manually
\def\pgf@circ@resistor@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{generic}{#1}\else\pgf@circ@bipole@path{resistor}{#1}\fi}
\pgfcirc@path@to@style{l}{resistor}{resistor}{}
\pgfcirc@node@to@style{l}{resistor}{american resistor}{}
\pgfcirc@node@to@style{l}{generic}{european resistor}{}
\pgfcirc@style@to@style{resistor}{R}

\def\pgf@circ@vresistor@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{tgeneric}{#1}\else\pgf@circ@bipole@path{vresistor}{#1}\fi}
\pgfcirc@path@to@style{l}{vresistor}{variable resistor}{}
\pgfcirc@node@to@style{l}{vresistor}{variable american resistor}{}
\pgfcirc@node@to@style{l}{tgeneric}{variable european resistor}{}
\pgfcirc@style@to@style{variable resistor}{vR}

\def\pgf@circ@resistivesens@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{thermistor}{#1}\else\pgf@circ@bipole@path{resistivesens}{#1}\fi}
\pgfcirc@path@to@style{l}{resistivesens}{resistive sensor}{}
\pgfcirc@node@to@style{l}{resistivesens}{american resistive sensor}{}
\pgfcirc@node@to@style{l}{thermistor}{european resistive sensor}{}
\pgfcirc@style@to@style{resistive sensor}{sR}

\def\pgf@circ@ldresistor@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{ldgeneric}{#1}\else\pgf@circ@bipole@path{ldresistor}{#1}\fi}
\pgfcirc@path@to@style{l}{ldresistor}{light dependent resistor}{}
\pgfcirc@node@to@style{l}{ldresistor}{american light dependent resistor}{}
\pgfcirc@node@to@style{l}{ldgeneric}{european light dependent resistor}{}
\pgfcirc@style@to@style{light dependent resistor}{ldR}

\def\pgf@circ@potentiometer@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{genericpotentiometer}{#1}\else\pgf@circ@bipole@path{potentiometer}{#1}\fi}
\pgfcirc@path@to@style{l}{potentiometer}{potentiometer}{}
\pgfcirc@node@to@style{l}{potentiometer}{american potentiometer}{}
\pgfcirc@node@to@style{l}{genericpotentiometer}{european potentiometer}{}
\pgfcirc@style@to@style{potentiometer}{pR}

\pgfcirc@activate@bipole@simple{l}{thermistor}
\pgfcirc@style@to@style{thermistor}{thR}
\pgfcirc@activate@bipole{l}{thermistorptc}{thermistorptc}{thermistor ptc}
\pgfcirc@style@to@style{thermistor ptc}{thRp}
\pgfcirc@activate@bipole{l}{thermistorntc}{thermistorntc}{thermistor ntc}
\pgfcirc@style@to@style{thermistor ntc}{thRn}
\pgfcirc@activate@bipole@simple{l}{photoresistor}
\pgfcirc@style@to@style{photoresistor}{phR}
\pgfcirc@activate@bipole@simple{l}{varistor}
\pgfcirc@activate@bipole@simple{l}{mov}
\pgfcirc@activate@bipole@simple{l}{memristor}
\pgfcirc@style@to@style{memristor}{Mr}%
% %>>>

%%%%%%%%%%%%%%
%% Capacitors
%%%%%%%%%%%%%

%% Definitions for Capacitors%<<<1
\ctikzset{bipoles/capacitor/height/.initial=.6}
\ctikzset{bipoles/capacitor/width/.initial=.2}
\ctikzset{bipoles/ecapacitor/height/.initial=.5}
\ctikzset{bipoles/ecapacitor/width/.initial=.2}
\ctikzset{bipoles/ecapacitor/font/.initial=\pgf@circ@font@sixbm}
%%% pcapacitor is deprecated
\ctikzset{bipoles/pcapacitor/height/.initial=.6}
\ctikzset{bipoles/pcapacitor/width/.initial=.2}
\ctikzset{bipoles/pcapacitor/bend width/.initial=1.1}
\ctikzset{bipoles/ccapacitor/height/.initial=.6}
\ctikzset{bipoles/ccapacitor/width/.initial=.2}
\ctikzset{bipoles/ccapacitor/bend width/.initial=1.1}
\ctikzset{bipoles/vcapacitor/height/.initial=.6}
\ctikzset{bipoles/vcapacitor/width/.initial=.2}
\ctikzset{bipoles/vcapacitor/tunable width/.initial=3}
\ctikzset{bipoles/vcapacitor/capacitor width/.code={%
        \pgfutil@packagewarning{circuitikz}{vcapacitor/capacitor width deprecated; ignored}%
}}% deprecated
% piezoelectric (double size by default)
\ctikzset{bipoles/piezoelectric/height/.initial=.7}
\ctikzset{bipoles/piezoelectric/width/.initial=.4}%
% constant phase element (double size by default)
\ctikzset{bipoles/cpe/height/.initial=.6}
\ctikzset{bipoles/cpe/width/.initial=.4}
%
% style settings
%
\ctikzset{capacitors/width/.code={%
    \pgfmathsetmacro{\pgfcirc@@double}{2*#1}%
    \ctikzset{bipoles/.cd,
    capacitor/width=#1, ecapacitor/width=#1, ccapacitor/width=#1,
    vcapacitor/width=#1,
    piezoelectric/width=\pgfcirc@@double,
    cpe/width=\pgfcirc@@double,
}}}
\ctikzset{capacitors/height/.code={%
    \ctikzset{bipoles/.cd,
    capacitor/height=#1, ecapacitor/height=#1, ccapacitor/height=#1,
    vcapacitor/height=#1,
    piezoelectric/height=#1,
    cpe/height=#1,
}}}
\def\pgfcirc@maybe@fill@straight@capacitor{%
    \pgfscope
        \pgfpathrectanglecorners
        {\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@maybefill
    \endpgfscope
}
%>>>

%% Shapes for capacitors%<<<
%% Plain Capacitor
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/capacitor/height}}
{capacitor}
{\ctikzvalof{bipoles/capacitor/height}}
{\ctikzvalof{bipoles/capacitor/width}}
{
    \pgfcirc@maybe@fill@straight@capacitor

    \pgf@circ@setlinewidth{bipoles}{\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}

}

%% Capacitive sensor
\pgfcircdeclarebipolescaled{capacitors}
{
    \anchor{label}{\southwest\pgf@x=2.6\pgf@x\pgf@y=1.2\pgf@y}%
    \pgfcirc@border@extend@full{2.6}{1}{4.4}{1.2}
    \anchor{wiper}{\northeast\pgf@x=-4.4\pgf@x\pgf@y=-1.2\pgf@y}
    \anchor{W}{\northeast\pgf@x=-4.4\pgf@x\pgf@y=-1.2\pgf@y}
    \anchor{tip}{\northeast\pgf@x=2.6\pgf@x}
}
{\ctikzvalof{bipoles/capacitor/height}}
{capacitivesens}
{\ctikzvalof{bipoles/capacitor/height}}
{\ctikzvalof{bipoles/capacitor/width}}
{
    \pgfcirc@maybe@fill@straight@capacitor
    \pgf@circ@setlinewidth{bipoles}{\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}
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{2.6\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-2.6\pgf@circ@res@right}{1.2\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-4.4\pgf@circ@res@right}{1.2\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Polar Capacitor (DEPRECATED)
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/pcapacitor/height}}
{polarcapacitor}
{\ctikzvalof{bipoles/pcapacitor/height}}
{\ctikzvalof{bipoles/pcapacitor/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgfutil@packagewarning{circuitikz}{polar capacitor has been deprecated; change to curved capacitor (see manual)}%

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


%% Curved capacitor
% see https://tex.stackexchange.com/questions/509594/polar-capacitor-orientation-in-circuitikz-seems-wrong
% for a rationale
%
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/ccapacitor/height}}
{ccapacitor}
{\ctikzvalof{bipoles/ccapacitor/height}}
{\ctikzvalof{bipoles/ccapacitor/width}}
{
    \pgfscope
        \pgfscope
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgftransformrotate{-90}
            \pgfpathsine{\pgfpoint{\pgf@circ@res@up}{-\ctikzvalof{bipoles/ccapacitor/bend width}\pgf@circ@res@right}}
            \pgfpathcosine{\pgfpoint{\pgf@circ@res@up}{\ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@right}}
            \pgftransformrotate{90}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathclose{}
            \pgf@circ@maybefill
        \endpgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfscope
            % \pgfsetcolor{red}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgftransformrotate{-90}
            \pgfpathsine{\pgfpoint{\pgf@circ@res@up}{-\ctikzvalof{bipoles/ccapacitor/bend width}\pgf@circ@res@right}}
            \pgfpathcosine{\pgfpoint{\pgf@circ@res@up}{\ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@right}}
            \pgfusepath{draw}
        \endpgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
    % extend wire to the curved capacitor
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\ctikzvalof{bipoles/pcapacitor/bend width}\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}

%% Electrolytic Capacitor
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/ecapacitor/height}}
{ecapacitor}
{\ctikzvalof{bipoles/ecapacitor/height}}
{\ctikzvalof{bipoles/ecapacitor/width}}
{
    \pgfscope
        \pgfsetrectcap
        % % % Draw plus pole
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgf@circ@draworfill
        % % Draw minus pole
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgf@circ@setcolor
        \pgf@circ@fill@strokecolor
        \pgfusepath{draw,fill}
    \endpgfscope
    % % plus pole annotation
    \pgf@circ@text@strokecolor
    \pgftext[right,at=\pgfpoint{1.2\pgf@circ@res@left}{.6\pgf@circ@res@up}]
    {\ctikzvalof{bipoles/ecapacitor/font} $+$}
}

%% Variable Capacitor
\pgfcircdeclarebipolescaled{capacitors}
{
    \saveddimen{\tunablewidth}{%
        \pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/vcapacitor/tunable width}*
            \ctikzvalof{bipoles/vcapacitor/width}*0.5*
            \ctikzvalof{\ctikzclass/scale}*\pgf@circ@Rlen}
    }
    \anchor{wiper}{\northeast\pgf@x=-\tunablewidth\pgf@y=-\pgf@y}
    \anchor{W}{\northeast\pgf@x=-\tunablewidth\pgf@y=-\pgf@y}
    \anchor{tip}{\northeast\pgf@x=\tunablewidth}
}
{\ctikzvalof{bipoles/vcapacitor/height}}
{vcapacitor}
{\ctikzvalof{bipoles/vcapacitor/height}}
{\ctikzvalof{bipoles/vcapacitor/width}}
{
    \pgfcirc@maybe@fill@straight@capacitor
    \pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/tunable width} \pgf@circ@res@right

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{-\pgf@circ@res@right}{\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}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \ifpgf@circ@fixtunable@dir
            \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
        \else
            \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
        \fi
        \pgfusepath{draw}
    \endpgfscope

    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfusepath{draw}
}


%% Piezoelectric Element

\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/piezoelectric/height}}
{piezoelectric}
{\ctikzvalof{bipoles/piezoelectric/height}}
{\ctikzvalof{bipoles/piezoelectric/width}}
{
    % \pgf@circ@res@step = \ctikzvalof{bipoles/piezoelectric/width}\pgf@circ@Rlen
    % \divide \pgf@circ@res@step by 5

    %% Outer markings
    \pgf@circ@setlinewidth{bipoles}{\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}

    %% Inner Box
    \pgf@circ@res@step = \pgf@circ@res@right \divide \pgf@circ@res@step by 10
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathrectanglecorners
            {\pgfpoint{\pgf@circ@res@left+4*\pgf@circ@res@step}{\pgf@circ@res@up-\pgf@circ@res@step}}
            {\pgfpoint{\pgf@circ@res@right-4*\pgf@circ@res@step}{\pgf@circ@res@down+\pgf@circ@res@step}}
        \pgf@circ@draworfill
    \endpgfscope
}

% Ferroelectric capacitor, suggested by Mayeul Cantan
% (see https://github.com/circuitikz/circuitikz/issues/515)
\pgfcircdeclarebipolescaled{capacitors}
{
    \anchor{curve right}{\southwest\pgf@x=-1.8\pgf@x\pgf@y=\pgf@y}%
    \anchor{curve left}{\southwest\pgf@x=1.8\pgf@x\pgf@y=-\pgf@y}%
    \anchor{kink right}{\southwest\pgf@x=-1.8\pgf@x\pgf@y=0.5\pgf@y}%
    \anchor{kink left}{\southwest\pgf@x=1.8\pgf@x\pgf@y=-0.5\pgf@y}%
    \pgfcirc@border@extend@full{1.8}{1}{1.8}{1}
}
{\ctikzvalof{bipoles/capacitor/height}}
{ferrocap}
{\ctikzvalof{bipoles/capacitor/height}}
{\ctikzvalof{bipoles/capacitor/width}}
{
    \pgfcirc@maybe@fill@straight@capacitor

    \pgf@circ@setlinewidth{bipoles}{\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}
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfsetcornersarced{\pgfpoint{0.2\pgf@circ@res@right}{0.2\pgf@circ@res@up}}
        \pgfpathmoveto{\pgfpoint{-1.8\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-1.8\pgf@circ@res@right}{0.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{1.8\pgf@circ@res@right}{0.5\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{1.8\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Constant phase element
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/cpe/height}}
{cpe}
{\ctikzvalof{bipoles/cpe/height}}
{\ctikzvalof{bipoles/cpe/width}}
{
    \pgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointorigin}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
        \pgfpathclose
        \pgf@circ@maybefill
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpointorigin}
    \pgfusepath{draw}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpointorigin}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}

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

% %>>>

%% Paths for capacitors%<<<
\pgfcirc@activate@bipole@simple{l}{capacitor}
\pgfcirc@style@to@style{capacitor}{C}
\pgfcirc@activate@bipole@simple{l}{ecapacitor}
\pgfcirc@style@to@style{ecapacitor}{eC}
\pgfcirc@style@to@style{ecapacitor}{elko}
\pgfcirc@activate@bipole{l}{polarcapacitor}{polarcapacitor}{polar capacitor}
%% polar capacitor is deprecated, use curved capacitor instead
\pgfcirc@style@to@style{polar capacitor}{pC}
\pgfcirc@activate@bipole{l}{ccapacitor}{ccapacitor}{curved capacitor}
\pgfcirc@style@to@style{curved capacitor}{cC}
\pgfcirc@activate@bipole{l}{vcapacitor}{vcapacitor}{variable capacitor}
\pgfcirc@style@to@style{variable capacitor}{vC}
\pgfcirc@activate@bipole@simple{l}{piezoelectric}
\pgfcirc@style@to@style{piezoelectric}{PZ}
\pgfcirc@activate@bipole{l}{capacitivesens}{capacitivesens}{capacitive sensor}
\pgfcirc@style@to@style{capacitive sensor}{sC}
\pgfcirc@activate@bipole@simple{l}{ferrocap}
\pgfcirc@style@to@style{ferrocap}{feC}
\pgfcirc@activate@bipole@simple{l}{cpe}
% %>>>

%%%%%%%%%%%%%%%
%% Inductors
%%%%%%%%%%%%%%%

% Definitions of Inductors%<<<1

\ctikzset{inductors/coils/.code={%
    \ctikzset{bipoles/cuteinductor/coils=#1}%
    \ctikzset{bipoles/cutechoke/coils=#1}%
    \ctikzset{bipoles/americaninductor/coils=#1}%
    \ctikzset{bipoles/vcuteinductor/coils=#1}%
    \ctikzset{bipoles/vamericaninductor/coils=#1}%
}}
\ctikzset{inductors/width/.code={%
    \ctikzset{bipoles/cuteinductor/width=#1}%
    \ctikzset{bipoles/cutechoke/width=#1}%
    \ctikzset{bipoles/americaninductor/width=#1}%
    \ctikzset{bipoles/vcuteinductor/width=#1}%
    \ctikzset{bipoles/vamericaninductor/width=#1}%
    \ctikzset{bipoles/fullgeneric/width=#1}%
    \ctikzset{bipoles/tfullgeneric/width=#1}%
}}
\ctikzset{bipoles/cuteinductor/height/.initial=.3}
\ctikzset{bipoles/cuteinductor/lower coil height/.initial=.15}
\ctikzset{bipoles/cuteinductor/width/.initial=.6}
\ctikzset{bipoles/cuteinductor/coils/.initial=5}
\ctikzset{bipoles/cuteinductor/coil aspect/.initial=.5}%percentage of inductor width, which is covered by lower coil
%% Cute choke settings
\ctikzset{bipoles/cutechoke/height/.initial=.3}
\ctikzset{bipoles/cutechoke/lower coil height/.initial=.15}
\ctikzset{bipoles/cutechoke/width/.initial=.6}
\ctikzset{bipoles/cutechoke/coils/.initial=5}
\ctikzset{bipoles/cutechoke/coil aspect/.initial=.5}%percentage of choke width, which is covered by lower coil
\ctikzset{bipoles/cutechoke/cstep/.initial=.3}
\ctikzset{bipoles/cutechoke/cdist/.initial=1.3}
\ctikzset{bipoles/cutechoke/cthick/.initial=1}
\newif\ifpgf@circuit@bipole@twolineschoke
\pgf@circuit@bipole@twolineschokefalse
\pgfkeys{/tikz/onelinechoke/.add code={}{\pgf@circuit@bipole@twolineschokefalse}}
\ctikzset{onelinechoke/.add code={}{\pgf@circuit@bipole@twolineschokefalse}}
\pgfkeys{/tikz/twolineschoke/.add code={}{\pgf@circuit@bipole@twolineschoketrue}}
\ctikzset{twolineschoke/.add code={}{\pgf@circuit@bipole@twolineschoketrue}}
%
% generic core anchor settings
\ctikzset{bipoles/inductors/core distance/.initial={2pt}}
\ctikzset{bipoles/inductors/dot x distance/.initial={4pt}}
\ctikzset{bipoles/inductors/dot y distance/.initial={1pt}}
\def\pgfcir@basic@core@anchors{%
    \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}}
    \saveddimen{\dotXdistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/dot x distance}}}
    \saveddimen{\dotYdistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/dot y distance}}}
    \anchor{core east}{%
        \northeast\advance\pgf@y by\coredistance
    }
    \anchor{core west}{%
        \northeast\advance\pgf@y by\coredistance\pgf@x=-\pgf@x
    }
    \anchor{ll dot}{%
        \southwestborder
        \advance\pgf@x by -\dotXdistance
        \advance\pgf@y by -\dotYdistance
    }
    \anchor{ul dot}{%
        \northeastborder
        \advance\pgf@x by \dotXdistance\pgf@x=-\pgf@x
        \advance\pgf@y by \dotYdistance
    }
    \anchor{lr dot}{%
        \southwestborder
        \advance\pgf@x by -\dotXdistance\pgf@x=-\pgf@x
        \advance\pgf@y by -\dotYdistance
    }
    \anchor{ur dot}{%
        \northeastborder
        \advance\pgf@x by \dotXdistance
        \advance\pgf@y by \dotYdistance
    }
}
%
\ctikzset{bipoles/americaninductor/height/.initial=.3}
\ctikzset{bipoles/americaninductor/height 2/.initial=.1}
\ctikzset{bipoles/americaninductor/width/.initial=.8}
\ctikzset{bipoles/americaninductor/coils/.initial=4}
\ctikzset{bipoles/americaninductor/coil height/.initial=.15}
\ctikzset{bipoles/vcuteinductor/height/.initial=.6}
\ctikzset{bipoles/vcuteinductor/lower coil height/.initial=.3}
\ctikzset{bipoles/vcuteinductor/width/.initial=.6}
\ctikzset{bipoles/vcuteinductor/coils/.initial=5}
\ctikzset{bipoles/vcuteinductor/coil aspect/.initial=.5}%percentage of inductor width, which is covered by lower coil
\ctikzset{bipoles/vamericaninductor/height/.initial=.6}
\ctikzset{bipoles/vamericaninductor/height 2/.initial=.2}
\ctikzset{bipoles/vamericaninductor/width/.initial=.8}
\ctikzset{bipoles/vamericaninductor/coils/.initial=4}
\ctikzset{bipoles/vamericaninductor/coil height/.initial=.15}
\ctikzset{bipoles/tfullgeneric/height/.initial=.70}
\ctikzset{bipoles/tfullgeneric/width/.initial=.80}
\ctikzset{bipoles/fullgeneric/height/.initial=.30}
\ctikzset{bipoles/fullgeneric/width/.initial=.80}
\ctikzset{inductor/.is choice}
\ctikzset{inductor/cute/.code={\ctikzsetvalof{inductor}{cute}}}
\ctikzset{inductor/european/.code={\ctikzsetvalof{inductor}{european}}}
\ctikzset{inductor/american/.code={\ctikzsetvalof{inductor}{american}}}

\tikzset{american inductors/.style = {\circuitikzbasekey/inductor = american}}
\tikzset{european inductors/.style = {\circuitikzbasekey/inductor = european}}
\tikzset{cute inductors/.style = {\circuitikzbasekey/inductor = cute}}
\tikzset{american ports/.style = {\circuitikzbasekey/logic ports = american}}
\tikzset{european ports/.style = {\circuitikzbasekey/logic ports = european}}

%%>>>

%% Shapes for inductors%<<<
%% cute inductor
\pgfcircdeclarebipolescaled{inductors}
{
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/cuteinductor/coils},2) ?%
            \ctikzvalof{bipoles/cuteinductor/height} :% even
            -\ctikzvalof{bipoles/cuteinductor/lower coil height}) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \pgfcir@basic@core@anchors
    }
{\ctikzvalof{bipoles/cuteinductor/lower coil height}}
{cuteinductor}
{\ctikzvalof{bipoles/cuteinductor/height}}
{\ctikzvalof{bipoles/cuteinductor/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments

    \pgfmathsetlength{\pgf@circ@res@other}%width of small coil
    {0.5*\ctikzvalof{bipoles/cuteinductor/coil aspect}*\ctikzvalof{bipoles/cuteinductor/width}*\scaledRlen/(\ctikzvalof{bipoles/cuteinductor/coils}-1)}


    \pgfmathsetlength{\pgf@circ@res@step}
    {(\ctikzvalof{bipoles/cuteinductor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment\pgflinewidth+(\ctikzvalof{bipoles/cuteinductor/coils}-1)*2*\pgf@circ@res@other)/\ctikzvalof{bipoles/cuteinductor/coils}/2}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {2,...,\ctikzvalof{bipoles/cuteinductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
        \pgfpatharc{0}{-180}{\pgf@circ@res@other and -\pgf@circ@res@down}
    }
    \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
}

%% cute inductive sensor
\pgfcircdeclarebipolescaled{inductors}
{% anchor for labelling the type of dependency
    \anchor{label}{\southwest\pgf@x=0.8\pgf@x\pgf@y=2.6\pgf@y}%
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/cuteinductor/coils},2) ?%
            \ctikzvalof{bipoles/cuteinductor/height} :% even
            -\ctikzvalof{bipoles/cuteinductor/lower coil height}) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \pgfcirc@border@extend@full{1}{2}{1.6}{2.6}
    \pgfcir@basic@core@anchors
    \anchor{wiper}{\southwest\pgf@x=1.6\pgf@x\pgf@y=2.6\pgf@y}
    \anchor{W}{\southwest\pgf@x=1.6\pgf@x\pgf@y=2.6\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.8\pgf@x\pgf@y=2\pgf@y}
}
{\ctikzvalof{bipoles/cuteinductor/lower coil height}}
{scuteinductor}
{\ctikzvalof{bipoles/cuteinductor/height}}
{\ctikzvalof{bipoles/cuteinductor/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments

    \pgfmathsetlength{\pgf@circ@res@other}%width of small coil
    {0.5*\ctikzvalof{bipoles/cuteinductor/coil aspect}*\ctikzvalof{bipoles/cuteinductor/width}*\scaledRlen/(\ctikzvalof{bipoles/cuteinductor/coils}-1)}


    \pgfmathsetlength{\pgf@circ@res@step}
    {(\ctikzvalof{bipoles/cuteinductor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment\pgflinewidth+(\ctikzvalof{bipoles/cuteinductor/coils}-1)*2*\pgf@circ@res@other)/\ctikzvalof{bipoles/cuteinductor/coils}/2}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {2,...,\ctikzvalof{bipoles/cuteinductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
        \pgfpatharc{0}{-180}{\pgf@circ@res@other and -\pgf@circ@res@down}
    }
    \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{.8\pgf@circ@res@right}{2\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-.8\pgf@circ@res@right}{2.6\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-1.6\pgf@circ@res@right}{2.6\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% cute choke
\pgfcircdeclarebipolescaled{inductors}
{
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/cuteinductor/coils},2) ?%
            \ctikzvalof{bipoles/cuteinductor/height} :% even
            -\ctikzvalof{bipoles/cuteinductor/lower coil height}) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
}
{\ctikzvalof{bipoles/cutechoke/lower coil height}}
{cutechoke}
{\ctikzvalof{bipoles/cutechoke/height}}
{\ctikzvalof{bipoles/cutechoke/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments

    \pgfmathsetlength{\pgf@circ@res@other}%width of small coil
    {0.5*\ctikzvalof{bipoles/cutechoke/coil aspect}*\ctikzvalof{bipoles/cutechoke/width}*\scaledRlen/(\ctikzvalof{bipoles/cutechoke/coils}-1)}


    \pgfmathsetlength{\pgf@circ@res@step}
    {(\ctikzvalof{bipoles/cutechoke/width}*\scaledRlen+\pgfhorizontaltransformationadjustment\pgflinewidth+(\ctikzvalof{bipoles/cutechoke/coils}-1)*2*\pgf@circ@res@other)/\ctikzvalof{bipoles/cutechoke/coils}/2}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {2,...,\ctikzvalof{bipoles/cutechoke/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
        \pgfpatharc{0}{-180}{\pgf@circ@res@other and -\pgf@circ@res@down}
    }
    \pgfpatharc{180}{0}{\pgf@circ@res@step and \pgf@circ@res@up}
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth+\ctikzvalof{bipoles/cutechoke/cdist}\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth+\ctikzvalof{bipoles/cutechoke/cdist}\pgf@circ@res@up}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfsetlinewidth{\ctikzvalof{bipoles/cutechoke/cthick}\pgflinewidth}
    \pgfusepath{stroke}

    \ifpgf@circuit@bipole@twolineschoke
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth+\ctikzvalof{bipoles/cutechoke/cdist}\pgf@circ@res@up+\ctikzvalof{bipoles/cutechoke/cstep}\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth+\ctikzvalof{bipoles/cutechoke/cdist}\pgf@circ@res@up+\ctikzvalof{bipoles/cutechoke/cstep}\pgf@circ@res@up}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfsetlinewidth{\ctikzvalof{bipoles/cutechoke/cthick}\pgflinewidth}
        \pgfusepath{stroke}
    \fi
}

%% variable cute inductor
\pgfcircdeclarebipolescaled{inductors}
{
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/cuteinductor/coils},2) ?%
            \ctikzvalof{bipoles/cuteinductor/height} :% even
            -\ctikzvalof{bipoles/cuteinductor/lower coil height}) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}}
    \anchor{core east}{%
        \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance
    }
    \anchor{core west}{%
        \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance\pgf@x=-\pgf@x
    }
    \anchor{wiper}{\southwest\pgf@x=0.4\pgf@x\pgf@y=\pgf@y}
    \anchor{W}{\southwest\pgf@x=0.4\pgf@x\pgf@y=\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.4\pgf@x}
}
{\ctikzvalof{bipoles/vcuteinductor/lower coil height}}
{vcuteinductor}
{\ctikzvalof{bipoles/vcuteinductor/height}}
{\ctikzvalof{bipoles/vcuteinductor/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments

    \pgfmathsetlength{\pgf@circ@res@other}%width of small coil
    {0.5*\ctikzvalof{bipoles/vcuteinductor/coil aspect}*\ctikzvalof{bipoles/vcuteinductor/width}*\scaledRlen/(\ctikzvalof{bipoles/vcuteinductor/coils}-1)}


    \pgfmathsetlength{\pgf@circ@res@step}
    {(\ctikzvalof{bipoles/vcuteinductor/width}*\scaledRlen+\pgfhorizontaltransformationadjustment\pgflinewidth+(\ctikzvalof{bipoles/vcuteinductor/coils}-1)*2*\pgf@circ@res@other)/\ctikzvalof{bipoles/vcuteinductor/coils}/2}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {2,...,\ctikzvalof{bipoles/vcuteinductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and .5\pgf@circ@res@up}
        \pgfpatharc{0}{-180}{\pgf@circ@res@other and -.5\pgf@circ@res@down}
    }
    \pgfpatharc{180}{0}{\pgf@circ@res@step and .5\pgf@circ@res@up}
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
}

%% american inductor
\pgfcircdeclarebipolescaled{inductors}
{
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/americaninductor/coils},2) ?%
            2*\ctikzvalof{bipoles/americaninductor/coil height} :% even
            0) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \pgfcir@basic@core@anchors
}
{\ctikzvalof{bipoles/americaninductor/height 2}}
{americaninductor}
{\ctikzvalof{bipoles/americaninductor/height}}
{\ctikzvalof{bipoles/americaninductor/width}}
{
    \pgf@circ@res@step=\ctikzvalof{bipoles/americaninductor/width}\pgf@circ@scaled@Rlen
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \advance \pgf@circ@res@step by \pgfhorizontaltransformationadjustment\pgflinewidth
    \divide \pgf@circ@res@step by \ctikzvalof{bipoles/americaninductor/coils}
    \divide \pgf@circ@res@step by 2
    \pgf@circ@res@other = \ctikzvalof{bipoles/americaninductor/coil height}\pgf@circ@scaled@Rlen

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {1,...,\ctikzvalof{bipoles/americaninductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and  \pgf@circ@res@other}
    }
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
}


%% american inductive sensor
\pgfcircdeclarebipolescaled{inductors}
{% anchor for labelling the type of dependency
    \anchor{label}{\southwest\pgf@x=0.8\pgf@x\pgf@y=2.6\pgf@y}%
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/americaninductor/coils},2) ?%
            2*\ctikzvalof{bipoles/americaninductor/coil height} :% even
            0) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \pgfcirc@border@extend@full{1}{2}{1.6}{2.6}
    \pgfcir@basic@core@anchors
    \anchor{wiper}{\southwest\pgf@x=1.6\pgf@x\pgf@y=2.6\pgf@y}
    \anchor{W}{\southwest\pgf@x=1.6\pgf@x\pgf@y=2.6\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.8\pgf@x\pgf@y=2\pgf@y}
}
{\ctikzvalof{bipoles/americaninductor/height 2}}
{samericaninductor}
{\ctikzvalof{bipoles/americaninductor/height}}
{\ctikzvalof{bipoles/americaninductor/width}}
{
    \pgf@circ@res@step=\ctikzvalof{bipoles/americaninductor/width}\pgf@circ@scaled@Rlen
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \advance \pgf@circ@res@step by \pgfhorizontaltransformationadjustment\pgflinewidth
    \divide \pgf@circ@res@step by \ctikzvalof{bipoles/americaninductor/coils}
    \divide \pgf@circ@res@step by 2
    \pgf@circ@res@other = \ctikzvalof{bipoles/americaninductor/coil height}\pgf@circ@scaled@Rlen

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {1,...,\ctikzvalof{bipoles/americaninductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and  \pgf@circ@res@other}
    }
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{.8\pgf@circ@res@right}{2\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-.8\pgf@circ@res@right}{2.6\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-1.6\pgf@circ@res@right}{2.6\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% variable american inductor
\pgfcircdeclarebipolescaled{inductors}
{
    \savedanchor{\midtap}{%
        \pgf@x=0pt\relax
        \pgfmathsetlength{\pgf@y}{%
            (mod(\ctikzvalof{bipoles/vamericaninductor/coils},2) ?%
            2*\ctikzvalof{bipoles/vamericaninductor/coil height} :% even
            0) %odd
            *\pgf@circ@scaled@Rlen/2
        }
    }
    \anchor{midtap}{\midtap}
    \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}}
    \anchor{core east}{%
        \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance
    }
    \anchor{core west}{%
        \northeast\pgf@y=0.5\pgf@y\advance\pgf@y by\coredistance\pgf@x=-\pgf@x
    }
    \anchor{wiper}{\southwest\pgf@x=0.4\pgf@x\pgf@y=\pgf@y}
    \anchor{W}{\southwest\pgf@x=0.4\pgf@x\pgf@y=\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.4\pgf@x}
}
{\ctikzvalof{bipoles/vamericaninductor/height 2}}
{vamericaninductor}
{\ctikzvalof{bipoles/vamericaninductor/height}}
{\ctikzvalof{bipoles/vamericaninductor/width}}
{
    \pgf@circ@res@step=\ctikzvalof{bipoles/vamericaninductor/width}\pgf@circ@scaled@Rlen
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \advance \pgf@circ@res@step by \pgfhorizontaltransformationadjustment\pgflinewidth
    \divide \pgf@circ@res@step by \ctikzvalof{bipoles/vamericaninductor/coils}
    \divide \pgf@circ@res@step by 2
    \pgf@circ@res@other = \ctikzvalof{bipoles/vamericaninductor/coil height}\pgf@circ@scaled@Rlen

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{-\pgfverticaltransformationadjustment*0.4*\pgfstartlinewidth}}%correct value would be 0.5 but arcs are not really flat, therefore 0.4 is better is (almost) all cases
    \foreach \x in {1,...,\ctikzvalof{bipoles/vamericaninductor/coils}}
    {
        \pgfpatharc{180}{0}{\pgf@circ@res@step and  \pgf@circ@res@other}
    }
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \pgfpathmoveto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-.4\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Generic bipole, filled - used as inductor by some
\pgfcircdeclarebipolescaled{inductors}
{
    \anchor{midtap}{\northeast\pgf@x=0pt\relax}
    \pgfcir@basic@core@anchors
}
{\ctikzvalof{bipoles/fullgeneric/height}}
{fullgeneric}
{\ctikzvalof{bipoles/fullgeneric/height}}
{\ctikzvalof{bipoles/fullgeneric/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgf@circ@fill@strokecolor
    \pgfusepath{draw,fill}
}

%% Generic sensor, filled - used as inductive sensor by some
\pgfcircdeclarebipolescaled{inductors}
{% anchor for labelling the type of dependency
    \anchor{label}{\southwest\pgf@x=0.4\pgf@x\pgf@y=2\pgf@y}%
    \anchor{midtap}{\northeast\pgf@x=0pt\relax}
    \pgfcirc@border@extend@full{1}{2}{1}{2}
    \pgfcir@basic@core@anchors
    \anchor{wiper}{\northeast\pgf@x=-\pgf@x\pgf@y=-2\pgf@y}
    \anchor{W}{\northeast\pgf@x=-\pgf@x\pgf@y=-2\pgf@y}
    \anchor{tip}{\northeast\pgf@y=2\pgf@y}
}
{\ctikzvalof{bipoles/fullgeneric/height}}
{sfullgeneric}
{\ctikzvalof{bipoles/fullgeneric/height}}
{\ctikzvalof{bipoles/fullgeneric/width}}
{

    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fill@strokecolor
    \pgfusepath{draw,fill}
    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{-2\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{2\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{2\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Generic full tunable
\pgfcircdeclarebipolescaled{inductors}
{
    \anchor{midtap}{\northeast\pgf@x=0pt\relax}
    \saveddimen{\coredistance}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{bipoles/inductors/core distance}}}
    \anchor{core east}{%
        \northeast\pgf@y=0.4\pgf@y\advance\pgf@y by \coredistance
    }
    \anchor{core west}{%
        \northeast\pgf@y=0.4\pgf@y\advance\pgf@y by \coredistance\pgf@x=-\pgf@x
    }
    \anchor{wiper}{\northeast\pgf@x=-0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{W}{\northeast\pgf@x=-0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{tip}{\northeast\pgf@x=0.5\pgf@x}
}
{\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}{.4\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{.4\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fill@strokecolor
    \pgfusepath{draw,fill}

    \pgfscope
        \pgf@circ@set@relative@thickness{modifier thickness}
        \pgfcirc@set@arrows{tunable}{}{latexslim}
        \ifpgf@circ@fixtunable@dir
            \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@up}}
        \else
            \pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{-.5\pgf@circ@res@left}{\pgf@circ@res@down}}
        \fi
        \pgfusepath{draw}
    \endpgfscope
}
% %>>>

%% Paths for Inductors%<<<
%% these are complex because of the three-way set
%% should be simplified
\def\pgf@circ@inductor@path#1{%
    \pgfextra{
        \edef\pgf@circ@temp{\ctikzvalof{inductor}}%
        \def\pgf@temp{european}%
    }
    \ifx\pgf@temp\pgf@circ@temp%
        \pgf@circ@europeaninductor@path{#1}%
    \else%
        \pgfextra{  \def\pgf@temp{cute} }%
        \ifx\pgf@temp\pgf@circ@temp%
            \pgf@circ@cuteinductor@path{#1}%
        \else%
            \pgf@circ@americaninductor@path{#1}%
        \fi%
    \fi%
}
\pgfcirc@path@to@style{l}{inductor}{inductor}{}
\pgfcirc@style@to@style{inductor}{L}
\pgfcirc@activate@bipole{l}{europeaninductor}{fullgeneric}{european inductor}
\pgfcirc@activate@bipole{l}{americaninductor}{americaninductor}{american inductor}
\pgfcirc@activate@bipole{l}{cuteinductor}{cuteinductor}{cute inductor}

\def\pgf@circ@vinductor@path#1{
    \pgfextra{
        \edef\pgf@circ@temp{\ctikzvalof{inductor}}%
        \def\pgf@temp{european}%
    }
    \ifx\pgf@temp\pgf@circ@temp%
        \pgf@circ@veuropeaninductor@path{#1}%
    \else%
        \pgfextra{  \def\pgf@temp{cute} }%
        \ifx\pgf@temp\pgf@circ@temp%
            \pgf@circ@vcuteinductor@path{#1}%
        \else%
            \pgf@circ@vamericaninductor@path{#1}%
        \fi%
    \fi%
}
\pgfcirc@path@to@style{l}{vinductor}{variable inductor}{}
\pgfcirc@style@to@style{variable inductor}{vL}
\pgfcirc@activate@bipole{l}{veuropeaninductor}{tfullgeneric}{variable european inductor}
\pgfcirc@activate@bipole{l}{vamericaninductor}{vamericaninductor}{variable american inductor}
\pgfcirc@activate@bipole{l}{vcuteinductor}{vcuteinductor}{variable cute inductor}

\def\pgf@circ@inductivesens@path#1{%
    \pgfextra{
        \edef\pgf@circ@temp{\ctikzvalof{inductor}}%
        \def\pgf@temp{european}%
    }
    \ifx\pgf@temp\pgf@circ@temp%
        \pgf@circ@europeaninductivesens@path{#1}%
    \else%
        \pgfextra{  \def\pgf@temp{cute} }%
        \ifx\pgf@temp\pgf@circ@temp%
            \pgf@circ@cuteinductivesens@path{#1}%
        \else%
            \pgf@circ@americaninductivesens@path{#1}%
        \fi%
    \fi%
}
\pgfcirc@path@to@style{l}{inductivesens}{inductive sensor}{}
\pgfcirc@style@to@style{inductive sensor}{sL}
\pgfcirc@activate@bipole{l}{europeaninductivesens}{sfullgeneric}{european inductive sensor}
\pgfcirc@activate@bipole{l}{americaninductivesens}{samericaninductor}{american inductive sensor}
\pgfcirc@activate@bipole{l}{cuteinductivesens}{scuteinductor}{cute inductive sensor}

\pgfcirc@activate@bipole{l}{cutechoke}{cutechoke}{cute choke}
% %>>>

%%%%%%%%%%%
%% Sources (batteries, independent, dependents and so on
%%%%%%%%%%%

% Definitions for Sources%<<<1

\ctikzset{bipoles/esource/height/.initial=.60}
\ctikzset{bipoles/esource/width/.initial=.60}
\ctikzset{bipoles/pvsource/height/.initial=.60}
\ctikzset{bipoles/pvsource/width/.initial=.60}
\ctikzset{bipoles/pvmodule/height/.initial=.60}
\ctikzset{bipoles/pvmodule/width/.initial=1.20}
\ctikzset{bipoles/isource/height/.initial=.60}
\ctikzset{bipoles/isource/width/.initial=.60}
\ctikzset{bipoles/oosource/height/.initial=.60}
\ctikzset{bipoles/oosource/width/.initial=.60}
\ctikzset{bipoles/oosource/circlesize/.initial=.65}%circlesize+circleoffset should be =1
\ctikzset{bipoles/oosource/circleoffset/.initial=.35}%circlesize+circleoffset should be =1
\ctikzset{bipoles/dcisource/angle/.initial=80}
\ctikzset{bipoles/dcisource/height/.initial=.60}
\ctikzset{bipoles/dcisource/width/.initial=.60}
\ctikzset{bipoles/dcvsource/height/.initial=.60}
\ctikzset{bipoles/dcvsource/width/.initial=.60}
\ctikzset{bipoles/vsourcetri/height/.initial=.60}
\ctikzset{bipoles/vsourcetri/width/.initial=.60}
\ctikzset{bipoles/isourceam/height/.initial=.60}
\ctikzset{bipoles/isourceam/width/.initial=.60}
\ctikzset{bipoles/vsource/height/.initial=.60}
\ctikzset{bipoles/vsource/width/.initial=.60}
\ctikzset{bipoles/vsourceam/height/.initial=.60}
\ctikzset{bipoles/vsourceam/width/.initial=.60}
\ctikzset{bipoles/vsourceam/margin/.initial=.7}
\ctikzset{bipoles/isourcesin/angle/.initial=90}
\ctikzset{bipoles/isourcesin/height/.initial=.60}
\ctikzset{bipoles/isourcesin/width/.initial=.60}
\ctikzset{bipoles/vsourcesin/height/.initial=.60}
\ctikzset{bipoles/vsourcesin/width/.initial=.60}
\ctikzset{bipoles/vsourcesquare/height/.initial=.60}
\ctikzset{bipoles/vsourcesquare/width/.initial=.60}
\ctikzset{bipoles/cisource/height/.initial=.7}
\ctikzset{bipoles/cisource/width/.initial=.7}
\ctikzset{bipoles/cisourceam/height/.initial=.7}
\ctikzset{bipoles/cisourceam/width/.initial=.7}
\ctikzset{bipoles/ecsource/height/.initial=.7}
\ctikzset{bipoles/ecsource/width/.initial=.7}
\ctikzset{bipoles/cvsource/height/.initial=.7}
\ctikzset{bipoles/cvsource/width/.initial=.7}
\ctikzset{bipoles/cvsourceam/height/.initial=.7}
\ctikzset{bipoles/cvsourceam/width/.initial=.7}
\ctikzset{bipoles/cvsourceam/margin/.initial=.7}
\ctikzset{bipoles/cvsourceam/text scale/.initial=1}
\ctikzset{bipoles/cisourcesin/width/.initial=.7}
\ctikzset{bipoles/cvsourcesin/height/.initial=.7}
\ctikzset{bipoles/cvsourcesin/width/.initial=.7}
\ctikzset{bipoles/battery/height/.initial=.6}
\ctikzset{bipoles/battery/width/.initial=.3}
\ctikzset{bipoles/battery1/height/.initial=.6}
\ctikzset{bipoles/battery1/width/.initial=.3}
\ctikzset{bipoles/battery2/height/.initial=.6}
\ctikzset{bipoles/battery2/width/.initial=.3}
% noise sources
\ctikzset{bipoles/noise sources/fillcolor/.initial=gray!50}

% for special symbols in the sources: sin, square, triangle, delta, wye, eyw, zig, etc.
\ctikzset{sources/symbol/thickness/.initial={1}}
\ctikzset{csources/symbol/thickness/.initial={1}}
\ctikzset{sources/symbol/rotate/.initial={90}}
\ctikzset{csources/symbol/rotate/.initial={90}}

% % % ootransformer
\ctikzset{bipoles/oosourcetrans/height/.initial=.6}
\ctikzset{bipoles/oosourcetrans/width/.initial=.6}
\ctikzset{bipoles/oosourcetrans/circlesize/.initial=.6}%circlesize+circleoffset should be =1
\ctikzset{bipoles/oosourcetrans/circleoffset/.initial=.4}%circlesize+circleoffset should be =1
\ctikzset{bipoles/oosourcetrans/vectorgroupscale/.initial=1}

% % % oootransformer
\ctikzset{bipoles/ooosource/height/.initial=.6}
\ctikzset{bipoles/ooosource/circlesize/.initial=.55}%circlesize+circleoffset should be =1
\ctikzset{bipoles/ooosource/circleoffset/.initial=.45}%circlesize+circleoffset should be =1
\ctikzset{bipoles/ooosource/vectorgroupscale/.initial=1}

% % % primary windings
\newif\ifpgf@circ@prim@delta
\newif\ifpgf@circ@prim@wye
\newif\ifpgf@circ@prim@eyw
\newif\ifpgf@circ@prim@zig
\pgfkeys{tikz/prim/.is choice}
\pgfkeys{tikz/prim/delta/.add code={}{\pgf@circ@prim@deltatrue}}
\pgfkeys{tikz/prim/wye/.add code={}{\pgf@circ@prim@wyetrue}}
\pgfkeys{tikz/prim/eyw/.add code={}{\pgf@circ@prim@eywtrue}}
\pgfkeys{tikz/prim/zig/.add code={}{\pgf@circ@prim@zigtrue}}

% % % secondary windings
\newif\ifpgf@circ@sec@delta
\newif\ifpgf@circ@sec@wye
\newif\ifpgf@circ@sec@eyw
\newif\ifpgf@circ@sec@zig
\pgfkeys{tikz/sec/.is choice}
\pgfkeys{tikz/sec/delta/.add code={}{\pgf@circ@sec@deltatrue}}
\pgfkeys{tikz/sec/wye/.add code={}{\pgf@circ@sec@wyetrue}}
\pgfkeys{tikz/sec/eyw/.add code={}{\pgf@circ@sec@eywtrue}}
\pgfkeys{tikz/sec/zig/.add code={}{\pgf@circ@sec@zigtrue}}

% % % tertiary windings (ooosource)
\newif\ifpgf@circ@tert@delta
\newif\ifpgf@circ@tert@wye
\newif\ifpgf@circ@tert@eyw
\newif\ifpgf@circ@tert@zig
\pgfkeys{tikz/tert/.is choice}
\pgfkeys{tikz/tert/delta/.add code={}{\pgf@circ@tert@deltatrue}}
\pgfkeys{tikz/tert/wye/.add code={}{\pgf@circ@tert@wyetrue}}
\pgfkeys{tikz/tert/eyw/.add code={}{\pgf@circ@tert@eywtrue}}
\pgfkeys{tikz/tert/zig/.add code={}{\pgf@circ@tert@zigtrue}}%

% nullator and norator
\ctikzset{bipoles/nullator/height/.initial=.30}
\ctikzset{bipoles/nullator/width/.initial=.60}
\ctikzset{bipoles/norator/height/.initial=.25}
\ctikzset{bipoles/norator/width/.initial=.60}%must be greater than 2*height

%%>>>

%% Nodes definitions for sources%<<<

%% Battery
\pgfcircdeclarebipolescaled{batteries}
{}
{\ctikzvalof{bipoles/battery/height}}
{battery}
{\ctikzvalof{bipoles/battery/height}}
{\ctikzvalof{bipoles/battery/width}}
{
    \pgf@circ@res@step = \ctikzvalof{bipoles/battery/width}\pgf@circ@scaled@Rlen
    \divide \pgf@circ@res@step by 6

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \ifpgf@circ@fixbatteries
        \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}}
    \else
        \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@step}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{.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@right}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{.5\pgf@circ@res@down}}
    \fi
    \pgfusepath{draw}
}


%% Battery 1 % poles with equl thickness

\pgfcircdeclarebipolescaled{batteries}
{}
{\ctikzvalof{bipoles/battery1/height}}
{battery1}
{\ctikzvalof{bipoles/battery1/height}}
{\ctikzvalof{bipoles/battery1/width}}
{
    \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfusepath{draw}

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \ifpgf@circ@fixbatteries
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@down}}
    \else
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@right}{.5\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@left}{\pgf@circ@res@down}}
    \fi
    \pgfusepath{draw}
}

%% Battery 2 % negative pole thicker

\pgfcircdeclarebipolescaled{batteries}
{}
{\ctikzvalof{bipoles/battery2/height}}
{battery2}
{\ctikzvalof{bipoles/battery2/height}}
{\ctikzvalof{bipoles/battery2/width}}
{
    \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfusepath{draw}

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \ifpgf@circ@fixbatteries
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \pgfsetlinewidth{3\pgflinewidth}
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@down}}
    \else
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \pgfsetlinewidth{3\pgflinewidth}
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@right}{.5\pgf@circ@res@down}}
    \fi
    \pgfusepath{draw}
}

%%%
%%% https://xkcd.com/2818/
%%% Also https://chat.stackexchange.com/transcript/message/64238058#64238058
%%%
\pgfcircdeclarebipolescaled{batteries}
{}
{\ctikzvalof{bipoles/battery/height}}
{baertty}
{\ctikzvalof{bipoles/battery/height}}
{\ctikzvalof{bipoles/battery/width}}
{
    \pgf@circ@res@step = \ctikzvalof{bipoles/battery/width}\pgf@circ@scaled@Rlen
    \divide \pgf@circ@res@step by 6
    \pgf@circ@setlinewidth{bipoles}{\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}{.5\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{.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@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfusepath{draw}
}
\pgfcirc@activate@bipole@simple@opt{v}{baertty}{\circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

%%%%%%%%%%%
%% Round and diamond sources
%%%%%%%%%%%

% % % symbol drawing macros (NOT for delta, wye, eyw, zig)
\def\pgf@circ@sources@symbol@setup{% called in a pgfscope
    \edef\@@@auto{auto}\edef\@@@rotate{\ctikzvalof{\ctikzclass/symbol/rotate}}
    \ifx\@@@auto\@@@rotate
        \pgfgettransformentries\a\b\temp\temp\temp\temp
        \pgfmathsetmacro{\@@@rotate}{-atan2(\b,\a)}
    \fi
    \pgftransformrotate{\@@@rotate}%
    \pgf@circ@set@relative@thickness{symbol/thickness}%
}

%% Independent voltage source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsource/height}}
{vsource}
{\ctikzvalof{bipoles/vsource/height}}
{\ctikzvalof{bipoles/vsource/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

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


%% macros for the sources with plus and minus internally
%% To change the internal symbols of the voltage source american style
\ctikzset{bipoles/vsourceam/inner plus/.initial={$+$}}
% In the mayority of fonts, the size of - is smaller than +, so we have
% unaligned signs when positioned independently.
% See https://github.com/circuitikz/circuitikz/issues/721
\ctikzset{bipoles/vsourceam/inner minus/.initial={$\vphantom{+}-$}}
%%
%% add the possibility to change the orientation of signs
\ctikzset{sources/symbol/sign rotation/.initial=default}% default, auto, or value
%% this should be more or less equivalent to \ctikzset{sources/symbol/sign rotation=90}, but it's font-dependent,
%% so you never know. Let's keep the traditional one here.
\def\pgf@circ@vsources@signs@default{%
    \ifpgf@circ@oldvoltagedirection
        \pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{\ctikzvalof{bipoles/vsourceam/inner plus}}%
        \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{\ctikzvalof{bipoles/vsourceam/inner minus}}%
    \else
        \pgftext[bottom,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@down]{\ctikzvalof{bipoles/vsourceam/inner minus}}%
        \pgftext[top,rotate=90,y=\ctikzvalof{bipoles/vsourceam/margin}\pgf@circ@res@up]{\ctikzvalof{bipoles/vsourceam/inner plus}}%
    \fi
}
\def\pgf@circ@vsources@sign@auto@or@fix{%
    \pgfgettransformentries\a\b\temp\temp\temp\temp
    \pgfmathsetmacro{\rot}{-atan2(\b,\a)}
    % the distance here is choosen so that it seems ok with standard fonts... probably, it must be changed.
    \pgfmathsetlength{\pgf@circ@res@temp}{%
        \ctikzvalof{bipoles/vsourceam/margin}*\pgf@circ@res@up
        -0.5*height("\ctikzvalof{bipoles/vsourceam/inner plus}")}
    \ifx\@@rotmode\@@auto
        \pgfmathsetmacro{\innerrot}{abs(\rot)<46?0:(abs(\rot)>134?0:90)}
    \else
        \ifx\@@rotmode\@@straight
            \pgfmathsetmacro{\innerrot}{\rot}
        \else
            \pgfmathsetmacro{\innerrot}{\@@rotmode}
        \fi
    \fi
    \ifpgf@circ@oldvoltagedirection
        \pgfscope
            \pgftransformxshift{\pgf@circ@res@temp}
            \pgftext[rotate=\innerrot]{\ctikzvalof{bipoles/vsourceam/inner plus}}
        \endpgfscope
        \pgfscope
            \pgftransformxshift{-\pgf@circ@res@temp}
            \pgftext[rotate=\innerrot]{\ctikzvalof{bipoles/vsourceam/inner minus}}
        \endpgfscope
    \else
        \pgfscope
            \pgftransformxshift{\pgf@circ@res@temp}
            \pgftext[rotate=\innerrot]{\ctikzvalof{bipoles/vsourceam/inner minus}}
        \endpgfscope
        \pgfscope
            \pgftransformxshift{-\pgf@circ@res@temp}
            \pgftext[rotate=\innerrot]{\ctikzvalof{bipoles/vsourceam/inner plus}}
        \endpgfscope
    \fi
}
\def\pgf@circ@vsources@draw@signs{%
    \edef\@@auto{auto}\edef\@@default{default}\edef\@@straight{straight}%
    \edef\@@rotmode{\ctikzvalof{sources/symbol/sign rotation}}%
    \ifx\@@rotmode\@@default
        \pgf@circ@vsources@signs@default
    \else
        \pgf@circ@vsources@sign@auto@or@fix
    \fi
}

%% Independent voltage source - American style
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsourceam/height}}
{vsourceAM}
{\ctikzvalof{bipoles/vsourceam/height}}
{\ctikzvalof{bipoles/vsourceam/width}}
{

    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@draworfill
    \endpgfscope
    \pgf@circ@text@strokecolor
    \pgf@circ@vsources@draw@signs
}

%% Independent sinusoidal voltage source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsourcesin/height}}
{vsourcesin}
{\ctikzvalof{bipoles/vsourcesin/height}}
{\ctikzvalof{bipoles/vsourcesin/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill

    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \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
}

% Square Voltage source -  contributed by Alistair Kwan
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsourcesquare/height}}
{vsourcesquare}
{\ctikzvalof{bipoles/vsourcesquare/height}}
{\ctikzvalof{bipoles/vsourcesquare/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \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
}

% Triangle Voltage source - contributed by Ralf Farkas
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsourcetri/height}}
{vsourcetri}
{\ctikzvalof{bipoles/vsourcetri/height}}
{\ctikzvalof{bipoles/vsourcetri/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill

    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \pgfpathmoveto{\pgfpoint{-1\pgf@circ@res@up}{0cm}}
        \pgfpathlineto{\pgfpoint{-0.5\pgf@circ@res@up}{0.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.5\pgf@circ@res@up}{-0.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{1\pgf@circ@res@up}{0\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

%% PV Source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/pvsource/height}}
{pvsource}
{\ctikzvalof{bipoles/pvsource/height}}
{\ctikzvalof{bipoles/pvsource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgf@circ@draworfill

    \pgfpathmoveto{\pgfpoint{.15\pgf@circ@res@right}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfpathmoveto{\pgfpoint{.15\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfusepath{draw}

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{.15\pgf@circ@res@left}{.4\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.15\pgf@circ@res@left}{.4\pgf@circ@res@down}}

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

    %Arrow Part
    \pgfscope
        \pgfsetarrowsend{latex}
        \pgfpathmoveto{\pgfpointadd{\pgfpoint{.3\pgf@circ@res@left}{0}}{\pgfpointpolar{-45}{2.2\pgf@circ@res@up}}}
        \pgfpathlineto{\pgfpointadd{\pgfpoint{.3\pgf@circ@res@left}{0}}{\pgfpointpolar{-45}{1.3\pgf@circ@res@up}}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpointadd{\pgfpoint{0}{0.3\pgf@circ@res@up}}{\pgfpointpolar{-45}{2.2\pgf@circ@res@up}}}
        \pgfpathlineto{\pgfpointadd{\pgfpoint{0}{0.3\pgf@circ@res@up}}{\pgfpointpolar{-45}{1.3\pgf@circ@res@up}}}
        \pgfusepath{draw}
    \endpgfscope

}

%% PV Module - contributed by Andre Alves
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/pvmodule/height}}
{pvmodule}
{\ctikzvalof{bipoles/pvmodule/height}}
{\ctikzvalof{bipoles/pvmodule/width}}
{

    % Draw rectangle
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathclose
    \pgf@circ@draworfill

    % Draw triangle
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0.5\pgf@circ@res@right}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@draworfill
    \pgfusepath{draw}
}

%% Empty Source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/esource/height}}
{esource}
{\ctikzvalof{bipoles/esource/height}}
{\ctikzvalof{bipoles/esource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
}

%% DC Current Source with open shape
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/dcisource/height}}
{dcisource}
{\ctikzvalof{bipoles/dcisource/height}}
{\ctikzvalof{bipoles/dcisource/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpointorigin}
    \pgfscope
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@maybefill
    \endpgfscope
    \edef\@@angle{\ctikzvalof{bipoles/dcisource/angle}}
    \pgfpathmoveto{\pgfpointpolar{\@@angle}{\pgf@circ@res@up}}
    \pgfpatharc{\@@angle}{-\@@angle}{\pgf@circ@res@up}
    \pgfpathmoveto{\pgfpointpolar{180-\@@angle}{\pgf@circ@res@up}}
    \pgfpatharc{180-\@@angle}{180+\@@angle}{\pgf@circ@res@up}
    \pgfusepath{draw}

    \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.6\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
}

%% DC-Voltage source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/dcvsource/height}}
{dcvsource}
{\ctikzvalof{bipoles/dcvsource/height}}
{\ctikzvalof{bipoles/dcvsource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \pgfpathmoveto{\pgfpoint{.2\pgf@circ@res@up}{.5\pgf@circ@res@left}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@up}{.5\pgf@circ@res@right}}
    \pgfpathmoveto{\pgfpoint{.2\pgf@circ@res@down}{.5\pgf@circ@res@left}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@down}{.5\pgf@circ@res@right}}
    \pgfusepath{draw}
}

%% Independent current source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isource/height}}
{isource}
{\ctikzvalof{bipoles/isource/height}}
{\ctikzvalof{bipoles/isource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgf@circ@draworfill
}

%% Independent double oo source
\pgfcircdeclarebipolescaled{sources}
{
    \anchor{centerprim}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=-\ctikzvalof{bipoles/oosource/circleoffset}\pgf@x
    }
    \anchor{centersec}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=\ctikzvalof{bipoles/oosource/circleoffset}\pgf@x
    }
}
{\ctikzvalof{bipoles/oosource/height}}
{oosource}
{\ctikzvalof{bipoles/oosource/height}}
{\ctikzvalof{bipoles/oosource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosource/circleoffset}\pgf@circ@res@left}{0}}
        {\ctikzvalof{bipoles/oosource/circlesize}\pgf@circ@res@left}
    \pgf@circ@maybefill
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosource/circleoffset}\pgf@circ@res@right}{0}}
        {\ctikzvalof{bipoles/oosource/circlesize}\pgf@circ@res@right}
    \pgf@circ@draworfill
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosource/circleoffset}\pgf@circ@res@left}{0}}
        {\ctikzvalof{bipoles/oosource/circlesize}\pgf@circ@res@left}
    \pgfusepath{draw}
}

% % % winding symbols
\ctikzset{sources/symbol/delta scale/.initial={1}}
\ctikzset{sources/symbol/wye scale/.initial={1}}
\ctikzset{sources/symbol/eyw scale/.initial={1}}
\ctikzset{sources/symbol/zig scale/.initial={1}}
% triangle
\def\pgf@circ@delta#1{
    \pgfscope
        \pgftransformscale{-.015*\ctikzvalof{\ctikzclass/symbol/delta scale}*\pgf@circ@res@left*#1}
        \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
            \pgftransformrotate{-\pgfcircmathresult}

        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@set@relative@thickness{symbol/thickness}
        % \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        % \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        % \pgfpathlineto{\pgfpoint{0}{.866\pgf@circ@res@up}}
        \pgfpathmoveto{\pgfpointpolar{90}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointpolar{-30}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointpolar{-150}{\pgf@circ@res@up}}
        \pgfpathclose
        \pgfusepath{stroke}
    \endpgfscope
}

% star
\def\pgf@circ@wye#1{
    \pgfscope
        \pgftransformscale{-.015*\ctikzvalof{\ctikzclass/symbol/wye scale}*\pgf@circ@res@left*#1}
        \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
            \pgftransformrotate{-\pgfcircmathresult}

        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@set@relative@thickness{symbol/thickness}
        \pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpointorigin}
        \pgfpathlineto{\pgfpointpolar{-30}{\pgf@circ@res@down}}
        \pgfpathmoveto{\pgfpointorigin}
        \pgfpathlineto{\pgfpointpolar{-150}{\pgf@circ@res@down}}
        \pgfusepath{stroke}
    \endpgfscope
}

% reverse star
\def\pgf@circ@eyw#1{
	\pgfscope
		\pgftransformscale{-.015*\ctikzvalof{\ctikzclass/symbol/eyw scale}*\pgf@circ@res@left*#1}
		\def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
			\pgftransformrotate{-\pgfcircmathresult}

		\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
		\pgf@circ@set@relative@thickness{symbol/thickness}
		\pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpointorigin}
		\pgfpathlineto{\pgfpointpolar{30}{\pgf@circ@res@down}}
		\pgfpathmoveto{\pgfpointorigin}
		\pgfpathlineto{\pgfpointpolar{150}{\pgf@circ@res@down}}
		\pgfusepath{stroke}
	\endpgfscope
}

% zigzag
\def\pgf@circ@zig#1{
    \pgfscope
        \pgftransformscale{-.015*\ctikzvalof{\ctikzclass/symbol/zig scale}*\pgf@circ@res@left*#1}
        \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
            \pgftransformrotate{-\pgfcircmathresult}

        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@set@relative@thickness{symbol/thickness}
        \pgfpathmoveto{\pgfpointorigin}
        \pgfpathlineto{\pgfpointpolar{90}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointpolar{60}{\pgf@circ@res@up}}

        \pgfpathmoveto{\pgfpointorigin}
        \pgfpathlineto{\pgfpointpolar{210}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointpolar{0}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpointorigin}
        \pgfpathlineto{\pgfpointpolar{330}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpointpolar{-60}{\pgf@circ@res@up}}
        \pgfusepath{stroke}
    \endpgfscope
}

% % % % round three-phase transformer
\pgfcircdeclarebipolescaled{sources}
{
    \anchor{centerprim}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=-\ctikzvalof{bipoles/oosourcetrans/circleoffset}\pgf@x
    }
    \anchor{centersec}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=\ctikzvalof{bipoles/oosourcetrans/circleoffset}\pgf@x
    }
    \anchor{symbolprim}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=-\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@x
    }
    \anchor{symbolsec}{
        \northeast
        \pgf@y=0pt\relax
        \pgf@x=\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@x
    }
}
{\ctikzvalof{bipoles/oosourcetrans/height}}
{oosourcetrans}
{\ctikzvalof{bipoles/oosourcetrans/height}}
{\ctikzvalof{bipoles/oosourcetrans/width}}
{

    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosourcetrans/circleoffset}\pgf@circ@res@left}{0}}
        {\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
    \pgf@circ@maybefill
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosourcetrans/circleoffset}\pgf@circ@res@right}{0}}
        {\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@right}
    \pgf@circ@draworfill
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/oosourcetrans/circleoffset}\pgf@circ@res@left}{0}}
        {\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
    \pgfusepath{draw}
    % % %     % draw inner symbols
    %%primary winding
    \ifpgf@circ@prim@delta
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
            \pgf@circ@delta{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@prim@wye
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
            \pgf@circ@wye{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

        \else\ifpgf@circ@prim@eyw
        \pgfscope
        \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
        \pgf@circ@eyw{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@prim@zig
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@left}
            \pgf@circ@zig{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope
    \fi\fi\fi\fi

    %%secondary winding
    \ifpgf@circ@sec@delta
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@right}
            \pgf@circ@delta{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@sec@wye
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@right}
            \pgf@circ@wye{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

        \else\ifpgf@circ@sec@eyw
        \pgfscope
        \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@right}
        \pgf@circ@eyw{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@sec@zig
        \pgfscope
            \pgftransformxshift{\ctikzvalof{bipoles/oosourcetrans/circlesize}\pgf@circ@res@right}
            \pgf@circ@zig{\ctikzvalof{bipoles/oosourcetrans/vectorgroupscale}}
        \endpgfscope
    \fi\fi\fi\fi
}


% % % % ooosource for three phase transformer
\pgfcircdeclarebipolescaled{sources}
{
    \anchor{right}{
            \northeast
            \pgf@y=0pt
            \pgfmathparse{
                \ctikzvalof{bipoles/ooosource/circleoffset}* sin(30) +
    %%the sqrt must be > 0, the circles have to intersect
                sqrt(
                    pow(\ctikzvalof{bipoles/ooosource/circlesize},2) -
                    pow(\ctikzvalof{bipoles/ooosource/circleoffset}*cos(30),2)
                )
            }
            \pgf@x=\pgfmathresult\pgf@x
    }
    \anchor{east}{
            \northeast
            \pgf@y=0pt
    }
    \savedanchor{\centerprim}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=-\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@other
            \pgf@y=0pt
            \pgf@x=.5\pgf@circ@res@other
    }
    \anchor{centerprim}{
            \centerprim
    }
    \savedanchor{\centersec}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=-\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@other
            \pgfpointpolar{60}{.5\pgf@circ@res@other}
            \pgf@y=-\pgf@y
            \pgf@x=-\pgf@x
    }
    \anchor{centersec}{
            \centersec
    }
    \savedanchor{\centertert}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=-\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@other
            \pgfpointpolar{60}{.5\pgf@circ@res@other}
            \pgf@y=\pgf@y
            \pgf@x=-\pgf@x
    }
    \anchor{centertert}{
            \centertert
    }
    % add some anchors in case the are needed :)
    \anchor{prim1}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centerprim}{\pgfpointpolar{135}{.5\pgf@circ@res@other}}
    }
    \anchor{prim2}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centerprim}{\pgfpointpolar{-135}{.5\pgf@circ@res@other}}
    }
    \anchor{sec1}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centersec}{\pgfpointpolar{0}{.5\pgf@circ@res@other}}
    }
    \anchor{sec2}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centersec}{\pgfpointpolar{45}{.5\pgf@circ@res@other}}
    }
    \anchor{sec3}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centersec}{\pgfpointpolar{90}{.5\pgf@circ@res@other}}
    }
    \anchor{tert1}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centertert}{\pgfpointpolar{0}{.5\pgf@circ@res@other}}
    }
    \anchor{tert2}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centertert}{\pgfpointpolar{-45}{.5\pgf@circ@res@other}}
    }
    \anchor{tert3}{
            \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@other=\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@other
            \pgfpointadd{\centertert}{\pgfpointpolar{-90}{.5\pgf@circ@res@other}}
    }
    % symbol "center" anchors
    \anchor{symbolprim}{
        \northeast
        \pgf@y=0pt
        \pgf@x=-0.6\pgf@x
    }
    \anchor{symbolsec}{
        \northeast
        \pgf@ya=\pgf@y
        \pgf@xa=\pgf@x
        \pgfpointpolar{60}{0.6\pgf@ya}
    }
    \anchor{symboltert}{
        \northeast
        \pgf@ya=\pgf@y
        \pgf@xa=\pgf@x
        \pgfpointpolar{-60}{0.6\pgf@ya}
    }
}
{\ctikzvalof{bipoles/ooosource/height}}
{ooosource}
{\ctikzvalof{bipoles/ooosource/height}}
{\ctikzvalof{bipoles/ooosource/height}}
{
%     \pgf@circ@res@other = \ctikzvalof{bipoles/ooosource/vectorgroup} \pgf@circ@scaled@Rlen

%     % filling
%     left
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@left}{0}}{\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@left}
    \pgf@circ@maybefill

    % up
    \pgfscope
        \pgfpointorigin
        \pgfpathcircle{\pgfpointpolar{60}{\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@right}}{\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@right}
        \pgf@circ@maybefill
    \endpgfscope
%     down
    \pgfscope
        \pgfpointorigin
        \pgfpathcircle{\pgfpointpolar{-60}{\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@right}}{\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@right}
        \pgf@circ@draworfill
    \endpgfscope

%     drawing
    % left
    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@left}{0}}{\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@left}
    \pgfusepath{draw}

    % up
    \pgfscope
        \pgfpointorigin
        \pgfpathcircle{\pgfpointpolar{60}{\ctikzvalof{bipoles/ooosource/circleoffset}\pgf@circ@res@right}}{\ctikzvalof{bipoles/ooosource/circlesize}\pgf@circ@res@right}
        \pgfusepath{draw}
    \endpgfscope

% % %     draw inner symbols

% %     primary winding
    \ifpgf@circ@prim@delta
        \pgfscope
            \pgftransformxshift{.6\pgf@circ@res@left}
            \pgf@circ@delta{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@prim@wye
        \pgfscope
            \pgftransformxshift{.6\pgf@circ@res@left}
            \pgf@circ@wye{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

        \else\ifpgf@circ@prim@eyw
        \pgfscope
        \pgftransformxshift{.6\pgf@circ@res@left}
        \pgf@circ@eyw{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@prim@zig
        \pgfscope
            \pgftransformxshift{.6\pgf@circ@res@left}
            \pgf@circ@zig{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope
    \fi\fi\fi\fi

% %     secondary winding
    \ifpgf@circ@sec@delta
        \pgfscope
            \pgfpointorigin
            \pgftransformshift{\pgfpointpolar{60}{0.6\pgf@circ@res@right}}
            \pgf@circ@delta{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@sec@wye
        \pgfscope
            \pgftransformshift{\pgfpointpolar{60}{0.6\pgf@circ@res@right}}
            \pgf@circ@wye{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

        \else\ifpgf@circ@sec@eyw
        \pgfscope
        \pgftransformshift{\pgfpointpolar{60}{0.6\pgf@circ@res@right}}
        \pgf@circ@eyw{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@sec@zig
        \pgfscope
            \pgftransformshift{\pgfpointpolar{60}{0.6\pgf@circ@res@right}}
            \pgf@circ@zig{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope
    \fi\fi\fi\fi

% %     tertiary winding
    \ifpgf@circ@tert@delta
        \pgfscope
            \pgftransformshift{\pgfpointpolar{-60}{0.6\pgf@circ@res@right}}
            \pgf@circ@delta{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@tert@wye
        \pgfscope
            \pgftransformshift{\pgfpointpolar{-60}{0.6\pgf@circ@res@right}}
            \pgf@circ@wye{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

        \else\ifpgf@circ@tert@eyw
        \pgfscope
        \pgftransformshift{\pgfpointpolar{-60}{0.6\pgf@circ@res@right}}
        \pgf@circ@eyw{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope

    \else\ifpgf@circ@tert@zig
        \pgfscope
            \pgftransformshift{\pgfpointpolar{-60}{0.6\pgf@circ@res@right}}
            \pgf@circ@zig{\ctikzvalof{bipoles/ooosource/vectorgroupscale}}
        \endpgfscope
    \fi\fi\fi\fi
}

%% Independent current source - American
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isourceam/height}}
{isourceAM}
{\ctikzvalof{bipoles/isourceam/height}}
{\ctikzvalof{bipoles/isourceam/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill

    \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 with open shape
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isource/height}}
{isourcesin}
{\ctikzvalof{bipoles/isource/height}}
{\ctikzvalof{bipoles/isource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@maybefill
    \endpgfscope
    \edef\@@angle{\ctikzvalof{bipoles/isourcesin/angle}}
    \pgfpathmoveto{\pgfpointpolar{\@@angle}{\pgf@circ@res@up}}
    \pgfpatharc{\@@angle}{-\@@angle}{\pgf@circ@res@up}
    \pgfpathmoveto{\pgfpointpolar{180-\@@angle}{\pgf@circ@res@up}}
    \pgfpatharc{180-\@@angle}{180+\@@angle}{\pgf@circ@res@up}
    \pgfusepath{draw}

    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \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
}

%% Empty controlled source
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/ecsource/height}}
{ecsource}
{\ctikzvalof{bipoles/ecsource/height}}
{\ctikzvalof{bipoles/ecsource/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgfpathclose
    \pgf@circ@draworfill
}

%% Controlled voltage source
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cvsource/height}}
{cvsource}
{\ctikzvalof{bipoles/cvsource/height}}
{\ctikzvalof{bipoles/cvsource/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgfpathclose
    \pgf@circ@draworfill

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
}

%% To change the internal symbols of the controlled voltage source american style
\ctikzset{bipoles/cvsourceam/inner plus/.initial={$+$}}
% In the mayority of fonts, the size of - is smaller than +, so we have
% unaligned signs when positioned independently.
% See https://github.com/circuitikz/circuitikz/issues/721
\ctikzset{bipoles/cvsourceam/inner minus/.initial={$\vphantom{+}-$}}
%% Controlled voltage source - American
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cvsourceam/height}}
{cvsourceAM}
{\ctikzvalof{bipoles/cvsourceam/height}}
{\ctikzvalof{bipoles/cvsourceam/width}}
{
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\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}}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope
    \pgf@circ@text@strokecolor
    \pgf@circ@vsources@draw@signs
}

%% Controlled sinusoidal voltage source
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cvsourcesin/height}}
{cvsourcesin}
{\ctikzvalof{bipoles/cvsourcesin/height}}
{\ctikzvalof{bipoles/cvsourcesin/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\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}}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope

    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \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
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cvsourcesin/height}}
{cisourcesin}
{\ctikzvalof{bipoles/cvsourcesin/height}}
{\ctikzvalof{bipoles/cvsourcesin/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\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}}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope

    \pgf@circ@res@up = .5\pgf@circ@res@up
    \pgfscope
        \pgf@circ@sources@symbol@setup
        \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
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cisource/height}}
{cisource}
{\ctikzvalof{bipoles/cisource/height}}
{\ctikzvalof{bipoles/cisource/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgfpathclose
    \pgf@circ@draworfill

    \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
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cisourceam/height}}
{cisourceAM}
{\ctikzvalof{bipoles/cisourceam/height}}
{\ctikzvalof{bipoles/cisourceam/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgfpathclose
    \pgf@circ@draworfill
    \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
}

%% Cute Independent voltage source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsource/height}}
{vsourceC}
{\ctikzvalof{bipoles/vsource/height}}
{\ctikzvalof{bipoles/vsource/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfsetroundcap\pgfusepath{draw}
}

%% Cute Independent current source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isource/height}}
{isourceC}
{\ctikzvalof{bipoles/isource/height}}
{\ctikzvalof{bipoles/isource/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{.6\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{.6\pgf@circ@res@down}}
    \pgfsetroundcap\pgfusepath{draw}
}

%% Cute Controlled voltage source
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cvsource/height}}
{cvsourceC}
{\ctikzvalof{bipoles/cvsource/height}}
{\ctikzvalof{bipoles/cvsource/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgf@circ@draworfill
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfsetroundcap\pgfusepath{draw}
}

%% Cute Controlled current source
\pgfcircdeclarebipolescaled{csources}
{}
{\ctikzvalof{bipoles/cisource/height}}
{cisourceC}
{\ctikzvalof{bipoles/cisource/height}}
{\ctikzvalof{bipoles/cisource/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\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}}
    \pgf@circ@draworfill
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@zero}{.6\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@zero}{.6\pgf@circ@res@down}}
    \pgfsetroundcap\pgfusepath{draw}
}

%%  Noise voltage source
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/vsource/height}}
{vsourceN}
{\ctikzvalof{bipoles/vsource/height}}
{\ctikzvalof{bipoles/vsource/width}}
{
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        %
        \pgf@circ@scaled@Rlen=\scaledRlen
        \pgf@circ@res@step=0.125\pgf@circ@scaled@Rlen\relax
        \edef\pgf@noise@temp{dashed}
        \edef\pgf@noise@fill{\ctikzvalof{bipoles/noise sources/fillcolor}}
        \ifx\pgf@noise@temp\pgf@noise@fill
            % fillable in this case
            \pgf@circ@draworfillandclip
            \pgfmathsetmacro{\@@thinner}{.5*\ctikzvalof{bipoles/thickness}}
            \pgfsetlinewidth{\@@thinner\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            %
            \advance\pgf@circ@res@up by -4\pgf@circ@res@step \advance\pgf@circ@res@down by -4\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by -\pgf@circ@res@step\advance\pgf@circ@res@down by -\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by -\pgf@circ@res@step\advance\pgf@circ@res@down by -\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \pgfusepath{draw}
        \else
            \pgfsetfillcolor{\pgf@noise@fill}
            \pgfusepath{draw,fill}
        \fi
    \endpgfscope
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfsetroundcap\pgfusepath{draw}
}
%% Noise current source

\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/isource/height}}
{isourceN}
{\ctikzvalof{bipoles/isource/height}}
{\ctikzvalof{bipoles/isource/width}}
{
    \pgfpointorigin
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        %
        \pgf@circ@scaled@Rlen=\scaledRlen
        \pgf@circ@res@step=0.125\pgf@circ@scaled@Rlen\relax
        \edef\pgf@noise@temp{dashed}
        \edef\pgf@noise@fill{\ctikzvalof{bipoles/noise sources/fillcolor}}
        \ifx\pgf@noise@temp\pgf@noise@fill
            % fillable in this case
            \pgf@circ@draworfillandclip
            \pgfmathsetmacro{\@@thinner}{.5*\ctikzvalof{bipoles/thickness}}
            \pgfsetlinewidth{\@@thinner\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by \pgf@circ@res@step\advance\pgf@circ@res@down by \pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            %
            \advance\pgf@circ@res@up by -4\pgf@circ@res@step \advance\pgf@circ@res@down by -4\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by -\pgf@circ@res@step\advance\pgf@circ@res@down by -\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \advance\pgf@circ@res@up by -\pgf@circ@res@step\advance\pgf@circ@res@down by -\pgf@circ@res@step
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \pgfusepath{draw}
        \else
            \pgfsetfillcolor{\pgf@noise@fill}
            \pgfusepath{draw,fill}
        \fi
    \endpgfscope
    \pgfmathsetmacro{\@@thicker}{3*\ctikzvalof{bipoles/thickness}}
    \pgfsetlinewidth{\@@thicker\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{.6\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{.6\pgf@circ@res@down}}
    \pgfsetroundcap\pgfusepath{draw}
}

% nullator
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/nullator/height}}
{nullator}
{\ctikzvalof{bipoles/nullator/height}}
{\ctikzvalof{bipoles/nullator/width}}
{
    \pgfpointorigin
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
}
% norator
\pgfcircdeclarebipolescaled{sources}
{}
{\ctikzvalof{bipoles/norator/height}}
{norator}
{\ctikzvalof{bipoles/norator/height}}
{\ctikzvalof{bipoles/norator/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@res@other=\dimexpr\pgf@circ@res@right-\pgf@circ@res@up\relax
    \pgfmathsetmacro{\@@angle}{atan2(\pgf@circ@res@other,\pgf@circ@res@up)}
    % \typeout{ANGLE\space\@@angle}
    \pgfmathsetlength{\pgf@circ@res@step}{\pgf@circ@res@up*cos(\@@angle)}
    \pgfmathsetlength{\pgf@circ@res@temp}{\pgf@circ@res@up*sin(\@@angle)}
    % right semicircle
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgf@circ@res@temp}}
    \pgfpatharc{180-\@@angle}{-180+\@@angle}{\pgf@circ@res@up}
    % connect to left semicircle
    \pgfpathlineto
        {\pgfpoint{-\pgf@circ@res@other+\pgf@circ@res@step}{\pgf@circ@res@temp}}
    % left semicircle
    \pgfpatharc{\@@angle}{360-\@@angle}{\pgf@circ@res@up}
    % connect to right semicircle
    \pgfpathlineto
        {\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgf@circ@res@temp}}
    \pgfpathclose
    \pgf@circ@draworfill
}

% %>>>

%% Paths definitions for Sources%<<<

%% Batteries

\pgfcirc@activate@bipole@simple@opt{v}{battery}{\circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@activate@bipole@opt{v}{batteryone}{battery1}{battery1}{\circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@activate@bipole@opt{v}{batterytwo}{battery2}{battery2}{\circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
%% Sources: voltage

\pgfcirc@activate@bipole@opt{v}{vsource}{vsource}{european voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@activate@bipole@opt{v}{vsourceam}{vsourceAM}{american voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=false}
\pgfcirc@style@to@style{\ifpgf@circuit@europeanvoltage european \else american \fi voltage source}{voltage source}
\pgfcirc@style@to@style{voltage source}{vsource}
\pgfcirc@style@to@style{voltage source}{V}

\pgfcirc@activate@bipole@opt{v}{cvsource}{cvsource}{european controlled voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@activate@bipole@opt{v}{cvsourceam}{cvsourceAM}{american controlled voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=false}
\pgfcirc@style@to@style{\ifpgf@circuit@europeanvoltage european \else american \fi controlled voltage source}{controlled voltage source}
\pgfcirc@style@to@style{controlled voltage source}{cvsource}
\pgfcirc@style@to@style{controlled voltage source}{controlled vsource}
\pgfcirc@style@to@style{controlled voltage source}{cV}

\pgfcirc@activate@bipole@simple@opt{v}{esource}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@opt{v}{ecsource}{ecsource}{empty controlled source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{empty controlled source}{ecsource}

\pgfcirc@activate@bipole@opt{v}{vsourcesin}{vsourcesin}{sinusoidal voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{sinusoidal voltage source}{vsourcesin}
\pgfcirc@style@to@style{sinusoidal voltage source}{sV}

\pgfcirc@activate@bipole@opt{v}{cvsourcesin}{cvsourcesin}{controlled sinusoidal voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{controlled sinusoidal voltage source}{cvsourcesin}
\pgfcirc@style@to@style{controlled sinusoidal voltage source}{controlled vsourcesin}
\pgfcirc@style@to@style{controlled sinusoidal voltage source}{csV}

\pgfcirc@activate@bipole@opt{v}{vsourcesquare}{vsourcesquare}{square voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{square voltage source}{vsourcesquare}
\pgfcirc@style@to@style{square voltage source}{sqV}

\pgfcirc@activate@bipole@opt{v}{vsourcetri}{vsourcetri}{triangle voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{triangle voltage source}{vsourcetri}
\pgfcirc@style@to@style{triangle voltage source}{tV}

\pgfcirc@activate@bipole@simple@opt{v}{pvsource}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@simple@opt{v}{pvmodule}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@simple@opt{v}{dcvsource}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@opt{v}{oosource}{oosource}{voosource}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@simple@opt{v}{ooosource}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@simple@opt{v}{oosourcetrans}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}

\pgfcirc@activate@bipole@opt{v}{vsourceC}{vsourceC}{cute european voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{cute european voltage source}{vsourceC}
\pgfcirc@style@to@style{cute european voltage source}{ceV}

\pgfcirc@activate@bipole@opt{v}{cvsourceC}{cvsourceC}{cute european controlled voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{cute european controlled voltage source}{cvsourceC}
\pgfcirc@style@to@style{cute european controlled voltage source}{cceV}

\pgfcirc@activate@bipole@opt{v}{vsourceN}{vsourceN}{noise voltage source}{%
    \circuitikzbasekey/bipole/is voltage=true,
    \circuitikzbasekey/bipole/is voltageoutsideofsymbol=true}
\pgfcirc@style@to@style{noise voltage source}{vsourceN}
\pgfcirc@style@to@style{noise voltage source}{nV}

%% Sources: current

\pgfcirc@activate@bipole@opt{i}{isource}{isource}{european current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@activate@bipole@opt{i}{isourceam}{isourceAM}{american current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{\ifpgf@circuit@europeancurrent european \else american \fi current source}{current source}
\pgfcirc@style@to@style{current source}{isource}
\pgfcirc@style@to@style{current source}{I}

\pgfcirc@activate@bipole@opt{i}{cisource}{cisource}{european controlled current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@activate@bipole@opt{i}{cisourceam}{cisourceAM}{american controlled current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{\ifpgf@circuit@europeanvoltage european \else american \fi controlled current source}{controlled current source}
\pgfcirc@style@to@style{controlled current source}{cisource}
\pgfcirc@style@to@style{controlled current source}{controlled isource}
\pgfcirc@style@to@style{controlled current source}{cI}

\pgfcirc@activate@bipole@opt{i}{isourcesin}{isourcesin}{sinusoidal current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{sinusoidal current source}{isourcesin}
\pgfcirc@style@to@style{sinusoidal current source}{sI}

\pgfcirc@activate@bipole@opt{i}{cisourcesin}{cisourcesin}{controlled sinusoidal current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{controlled sinusoidal current source}{cisourcesin}
\pgfcirc@style@to@style{controlled sinusoidal current source}{controlled isourcesin}
\pgfcirc@style@to@style{controlled sinusoidal current source}{csI}

\pgfcirc@activate@bipole@simple@opt{i}{dcisource}{%
    \circuitikzbasekey/bipole/is current=true}

\pgfcirc@activate@bipole@opt{i}{oosource}{oosource}{ioosource}{%
    \circuitikzbasekey/bipole/is current=true}

\pgfcirc@activate@bipole@opt{i}{isourceC}{isourceC}{cute european current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{cute european current source}{isourceC}
\pgfcirc@style@to@style{cute european current source}{ceI}

\pgfcirc@activate@bipole@opt{i}{cisourceC}{cisourceC}{cute european controlled current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{cute european controlled current source}{cisourceC}
\pgfcirc@style@to@style{cute european controlled current source}{cceI}

\pgfcirc@activate@bipole@opt{i}{isourceN}{isourceN}{noise current source}{%
    \circuitikzbasekey/bipole/is current=true}
\pgfcirc@style@to@style{noise current source}{isourceN}
\pgfcirc@style@to@style{noise current source}{nI}

% norator, nullator
\pgfcirc@activate@bipole@simple{l}{nullator}
\pgfcirc@activate@bipole@simple{l}{norator}

% build alias with voltage and current directions (legacy)

\def\pgf@temp#1{
    \pgfcirc@style@to@style@label{voltage source}{V#1}{v#1}
    \pgfcirc@style@to@style@label{controlled voltage source}{cV#1}{v#1}
    \pgfcirc@style@to@style@label{sinusoidal voltage source}{sV#1}{v#1}
    \pgfcirc@style@to@style@label{controlled sinusoidal voltage source}{csV#1}{v#1}
}
\pgf@temp{_>} \pgf@temp{_<} \pgf@temp{^>} \pgf@temp{^<}
\pgf@temp{>} \pgf@temp{<} \pgf@temp{^} \pgf@temp{_}
\def\pgf@temp#1{
    \pgfcirc@style@to@style@label{current source}{I#1}{i#1}
    \pgfcirc@style@to@style@label{controlled current source}{cI#1}{i#1}
    \pgfcirc@style@to@style@label{sinusoidal current source}{sI#1}{i#1}
    \pgfcirc@style@to@style@label{controlled sinusoidal current source}{csI#1}{i#1}
}
\pgf@temp{_>} \pgf@temp{_<} \pgf@temp{^>} \pgf@temp{^<}
\pgf@temp{>_} \pgf@temp{<_} \pgf@temp{>^} \pgf@temp{<^}
\pgf@temp{>} \pgf@temp{<} \pgf@temp{^} \pgf@temp{_}
% %>>>


%%%%%%%%%%%%%%
%% Diodes
%%%%%%%%%%%%%%

% Definitions for diodes%<<<1

\ctikzset{bipoles/diode/height/.initial=.50}
\ctikzset{bipoles/diode/width/.initial=.40}
% for horizontally-double-sided diodes, like tvs diodes (transorb)
\ctikzset{bipoles/ddiode/width/.initial=.80}% must be 2*diode width
% for vertically taller diodes
\ctikzset{bipoles/bidirectionaldiode/height/.initial=1.1}
\ctikzset{bipoles/bidirectionaldiode/width/.initial=1}
\ctikzset{bipoles/bidirectionaldiode/diode width left/.initial=.3}
\ctikzset{bipoles/bidirectionaldiode/diode width right/.initial=.3}
\ctikzset{bipoles/varcap/height/.initial=.50}
\ctikzset{bipoles/varcap/width/.initial=.45}

\ctikzset{tripoles/thyristor/height/.initial=1.10}
\ctikzset{tripoles/thyristor/height 2/.initial=.5}
\ctikzset{tripoles/thyristor/width/.initial=1.0}
\ctikzset{tripoles/thyristor/diode height/.initial=.5}
\ctikzset{tripoles/thyristor/diode width left/.initial=.4}
\ctikzset{tripoles/thyristor/diode width right/.initial=.3}
\ctikzset{tripoles/thyristor/gate height/.initial=0.0} % legacy 0
\ctikzset{tripoles/thyristor/gate kink/.initial=1.0} % legacy 1.0
\ctikzset{tripoles/thyristor/gto space up/.initial=0.5} % legacy 0.5
\ctikzset{tripoles/thyristor/gto space down/.initial=0.0} % legacy 0.0
\ctikzset{tripoles/thyristor/gto bar width/.initial=0.2} % legacy 0.2

\ctikzset{tripoles/triac/height/.initial=1.1}
\ctikzset{tripoles/triac/width/.initial=1}
\ctikzset{tripoles/triac/diode width left/.initial=.3}
\ctikzset{tripoles/triac/diode width right/.initial=.3}
\ctikzset{tripoles/triac/gate kink/.initial=1}

\ctikzset{thyristor style/.is choice}
\ctikzset{thyristor style/legacy/.code={%
    \ctikzset{tripoles/thyristor/height=1.1}%
    \ctikzset{tripoles/thyristor/height 2=.5}%
    \ctikzset{tripoles/thyristor/width=1.0}%
    \ctikzset{tripoles/thyristor/diode height=.5}%
    \ctikzset{tripoles/thyristor/diode width left=.4}%
    \ctikzset{tripoles/thyristor/diode width right=.3}%
    \ctikzset{tripoles/thyristor/gate height=0.0}%
    \ctikzset{tripoles/thyristor/gate kink=1.0}%
    \ctikzset{tripoles/thyristor/gto space up=0.5}%
    \ctikzset{tripoles/thyristor/gto space down=0.0}%
    \ctikzset{tripoles/thyristor/gto bar width=0.2}%
    \ctikzset{tripoles/triac/gate kink=1}%
}}
\ctikzset{thyristor style/compact/.code={%
    \ctikzset{tripoles/thyristor/height=0.8}% legacy 1.1
    \ctikzset{tripoles/thyristor/height 2=.5}%
    \ctikzset{tripoles/thyristor/width=1.0}%
    \ctikzset{tripoles/thyristor/diode height=.5}%
    \ctikzset{tripoles/thyristor/diode width left=.4}%
    \ctikzset{tripoles/thyristor/diode width right=.4}%legacy 0.3
    \ctikzset{tripoles/thyristor/gate height=0.5}% legacy 0
    \ctikzset{tripoles/thyristor/gate kink=0.7}% legacy 1.0
    \ctikzset{tripoles/thyristor/gto space up=0.25}% legacy 0.5
    \ctikzset{tripoles/thyristor/gto space down=0.25}% legacy 0.0
    \ctikzset{tripoles/thyristor/gto bar width=0.2}%
    \ctikzset{tripoles/triac/gate kink=.7}%
}}

%
% Flipping arrows in LED and photodiodes
%
\newif\ifpgf@led@fliparrows
\newif\ifpgf@pd@fliparrows
\pgf@led@fliparrowsfalse
\pgf@pd@fliparrowsfalse
%
% by default the arrows start (LED) and go (PD) to the anode.
%
\ctikzset{led arrows from anode/.code=\pgf@led@fliparrowsfalse}
\ctikzset{pd arrows to anode/.code=\pgf@pd@fliparrowsfalse}
%
% but they can start form the cathode (LED) or go to it (PD)
%
\ctikzset{led arrows from cathode/.code=\pgf@led@fliparrowstrue}
\ctikzset{pd arrows to cathode/.code=\pgf@pd@fliparrowstrue}

\newif\ifpgf@circuit@strokediode
\newif\ifpgf@circuit@fulldiode
\pgf@circuit@strokediodefalse
\pgf@circuit@fulldiodefalse

\ctikzset{diode/.is choice}
\ctikzset{diode/empty/.code = \pgf@circuit@fulldiodefalse\pgf@circuit@strokediodefalse}%default
\ctikzset{diode/full/.code = \pgf@circuit@fulldiodetrue }
\ctikzset{diode/stroke/.code = \pgf@circuit@strokediodetrue}

\tikzset{full diodes/.style = { \circuitikzbasekey/diode = full}}
\tikzset{empty diodes/.style = { \circuitikzbasekey/diode = empty}}
\tikzset{stroke diodes/.style = { \circuitikzbasekey/diode = stroke}}

%%>>>

%% Node components for diodes %<<<1

% beware, this shift to the left the coordinates
\def\pgf@circ@fulldiode@triangle@shift{%
        \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}}
        \pgf@circ@fill@strokecolor
        \pgfusepath{draw,fill}
        % \pgf@circ@debug@colors
}

%% Black generic diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{fulldiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@fulldiode@triangle@shift
    \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
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{fullzdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fulldiode@triangle@shift
    \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}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.6\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}

%% Black alternative zigzag Zener diode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.3}{1.3}
}
{\ctikzvalof{bipoles/diode/height}}
{fullzzdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fulldiode@triangle@shift
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-1.8\pgf@circ@res@left}{\pgf@circ@res@down-0.5\pgf@circ@res@up}}
    \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-0.2\pgf@circ@res@left}{\pgf@circ@res@up-0.5\pgf@circ@res@down}}
    \pgfusepath{draw}
}

%% Black Schottky diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{fullsdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fulldiode@triangle@shift
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.6\pgf@circ@res@left}{.6\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.6\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.4\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.4\pgf@circ@res@left}{.6\pgf@circ@res@up}}
    \pgfusepath{draw}
}

%% Black tunnel diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{fulltdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@fulldiode@triangle@shift
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.6\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-.6\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}
% the styling of optical arrows is defined in pgfcirc.define.tex because
% they are common to phototransistors

%
% draw LED arrows
%
\def\pgf@circ@draw@ledarrows{%
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgf@circ@fill@strokecolor
    \pgf@circ@set@optoarrow@style
    \ifpgf@led@fliparrows
        \pgfpathmoveto{\pgfpoint{0pt}{0.8\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-0.6\pgf@circ@res@right}{1.8\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{0.6\pgf@circ@res@right}{0.6\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{1.6\pgf@circ@res@up}}
        \pgfusepath{draw}
    \else
        \pgfpathmoveto{\pgfpoint{-0.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.6\pgf@circ@res@right}{2\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{0.2\pgf@circ@res@right}{0.8\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{1.2\pgf@circ@res@right}{1.8\pgf@circ@res@up}}
        \pgfusepath{draw}
    \fi
}
%
% ---and photodiode arrows
%
\def\pgf@circ@draw@pdarrows{%
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgf@circ@fill@strokecolor
    \pgf@circ@set@optoarrow@style
    \ifpgf@pd@fliparrows
        \pgfpathmoveto{\pgfpoint{-0.6\pgf@circ@res@right}{1.8\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{0.8\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{0pt}{1.6\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.6\pgf@circ@res@right}{0.6\pgf@circ@res@up}}
        \pgfusepath{draw}
    \else
        \pgfpathmoveto{\pgfpoint{0.6\pgf@circ@res@right}{2\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-0.4\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfusepath{draw}
        \pgfpathmoveto{\pgfpoint{1.2\pgf@circ@res@right}{1.8\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0.2\pgf@circ@res@right}{0.8\pgf@circ@res@up}}
        \pgfusepath{draw}
    \fi
}
%
% --and laser diode arrows - contributed by Andre Alves
%
\def\pgf@circ@draw@laserarrows{%
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgf@circ@fill@strokecolor
    \pgf@circ@set@optoarrow@style
    \pgfpathmoveto{\pgfpoint{-0.4\pgf@circ@res@right}{1.1\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{-0.4\pgf@circ@res@right}{2.1\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfpathmoveto{\pgfpoint{0.2\pgf@circ@res@right}{1.1\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0.2\pgf@circ@res@right}{2.1\pgf@circ@res@up}}
    \pgfusepath{draw}
}

\def\pgf@circ@generate@diode@saved@arrows#1#2#3#4#5{%
    \savedanchor{\arrows}{%
        \pgf@circ@scaled@Rlen=\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen
        \pgf@ya=\ctikzvalof{bipoles/diode/height}\pgf@circ@scaled@Rlen
        \pgf@xa=\ctikzvalof{bipoles/diode/width}\pgf@circ@scaled@Rlen
        \pgf@x=.5\pgf@xa\pgf@y=.5\pgf@ya
        \csname ifpgf@#5@fliparrows\endcsname
            \pgf@x=#1\pgf@x\pgf@y=#2\pgf@y
        \else
            \pgf@x=#3\pgf@x\pgf@y=#4\pgf@y
        \fi
    }
}
%% Black light emitting diode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.2}{2.0}{1.0}{2.0}{led}
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{fulllediode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@fulldiode@triangle@shift
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgf@circ@draw@ledarrows
}

%% Black laser diode - contributed by Andre Alves
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.1}{2.2}{-0.1}{2.2}{pd}%pd or led dosen't matter
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{fulllaserdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@fulldiode@triangle@shift
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgf@circ@draw@laserarrows
}

%% Black photodiode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.2}{2.0}{1.0}{2.0}{pd}
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{fullpdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@fulldiode@triangle@shift
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgf@circ@draw@pdarrows
}

%% Black varcap
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/varcap/height}}
{fullvarcap}
{\ctikzvalof{bipoles/varcap/height}}
{\ctikzvalof{bipoles/varcap/width}}
{
    \pgf@circ@res@temp=\ctikzvalof{bipoles/thickness}\pgfstartlinewidth
    \pgfsetlinewidth{\pgf@circ@res@temp}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
    \pgf@circ@fill@strokecolor
    \pgfusepath{draw,fill}
    %
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}

%% Code for the diode triangle
\def\pgf@circ@basicdiodeshape{
    % \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}}
        \pgfpathclose
        \pgf@circ@draworfill
        \pgfscope
            % to allow filling, we need to draw explicitly the stroke here.
            \pgfsetlinewidth{\pgfstartlinewidth}
            \ifpgf@circuit@bipole@strokedsymbol
                \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@left}{0pt}}
                \pgfpathlineto{\pgfpoint{0pt}{0pt}}
                \pgfusepath{draw}
            \fi
        \endpgfscope
    % \endpgfscope
}

%% Empty generic diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{emptydiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
    \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
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{emptyzdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgfscope
        \pgf@circ@basicdiodeshape
        \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}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-0.6\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Empty alternative zigzag Zener diode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.3}{1.3}
}
{\ctikzvalof{bipoles/diode/height}}
{emptyzzdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgfscope
        \pgf@circ@basicdiodeshape
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-1.8\pgf@circ@res@left}{\pgf@circ@res@down-0.5\pgf@circ@res@up}}
        \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-0.2\pgf@circ@res@left}{\pgf@circ@res@up-0.5\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}
%% Empty Schottky diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{emptysdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.6\pgf@circ@res@left}{.6\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-.6\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.4\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-1.4\pgf@circ@res@left}{.6\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope

}

%% Empty tunnel diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{emptytdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-.6\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-.6\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

%% Empty light emitting diode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.2}{2.0}{1.0}{2.0}{led}
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{emptylediode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}

    \pgf@circ@draw@ledarrows
}

%% Empty laser diode - contributed by Andre Alves
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.1}{2.2}{-0.1}{2.2}{pd}%pd or led dosen't matter
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{emptylaserdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfusepath{draw}

    \pgf@circ@draw@laserarrows
}

%% Empty photodiode
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.8}{1}
    \pgf@circ@generate@diode@saved@arrows{-0.2}{2.0}{1.0}{2.0}{pd}
    \anchor{arrows}{\arrows}
}
{\ctikzvalof{bipoles/diode/height}}
{emptypdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgf@circ@basicdiodeshape
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}

    \pgf@circ@draw@pdarrows
}

%% Empty varcap
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/varcap/height}}
{emptyvarcap}
{\ctikzvalof{bipoles/varcap/height}}
{\ctikzvalof{bipoles/varcap/width}}
{
    \pgf@circ@res@temp=\ctikzvalof{bipoles/thickness}\pgfstartlinewidth
    \pgfsetlinewidth{\pgf@circ@res@temp}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    % \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
    \pgfpathclose
    \pgf@circ@draworfill
    \pgfscope
        % to allow filling, we need to draw explicitily the stroke here.
        \pgfsetlinewidth{\pgfstartlinewidth}
        \ifpgf@circuit@bipole@strokedsymbol
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfusepath{draw}
        \fi
    \endpgfscope
    %
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}

%% Transorbs
%% Empty zigzag TVS diode (transorb)
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.3}{1.3}
}
{\ctikzvalof{bipoles/diode/height}}
{emptytvsdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/ddiode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfscope
            \pgftransformxscale{0.5}
            \pgftransformxshift{\pgf@circ@res@left}
            \pgf@circ@basicdiodeshape
        \endpgfscope
        \pgfscope
            \pgftransformxscale{-0.5}
            \pgftransformxshift{\pgf@circ@res@left}
            \pgf@circ@basicdiodeshape
        \endpgfscope
        \pgfpathmoveto{\pgfpoint{0.4\pgf@circ@res@left}{1.3\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{0.4\pgf@circ@res@right}{1.3\pgf@circ@res@down}}
        \pgfusepath{draw}
    \endpgfscope
}
%% Black zigzag TVS diode (transorb)
\pgfcircdeclarebipolescaled{diodes}
{% fix the anchor border
    \pgfcirc@border@extend@updown{1.3}{1.3}
}
{\ctikzvalof{bipoles/diode/height}}
{fulltvsdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/ddiode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgftransformxscale{0.5}
        \pgftransformxshift{\pgf@circ@res@left}
        \pgf@circ@fulldiode@triangle@shift
    \endpgfscope
    \pgfscope
        \pgftransformxscale{-0.5}
        \pgftransformxshift{\pgf@circ@res@left}
        \pgf@circ@fulldiode@triangle@shift
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{0.4\pgf@circ@res@left}{1.3\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{0.4\pgf@circ@res@right}{1.3\pgf@circ@res@down}}
    \pgfusepath{draw}
}

%% Black Shockley diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{fullshdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathclose
        \pgf@circ@fill@strokecolor
        \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}
}
%% Empty generic diode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/diode/height}}
{emptyshdiode}
{\ctikzvalof{bipoles/diode/height}}
{\ctikzvalof{bipoles/diode/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}

%% Empty bidirectionaldiode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/bidirectionaldiode/height}}
{emptybidirectionaldiode}
{\ctikzvalof{bipoles/bidirectionaldiode/height}}
{\ctikzvalof{bipoles/bidirectionaldiode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgf@circ@res@other = \ctikzvalof{bipoles/bidirectionaldiode/diode width left}\pgf@circ@res@left
    \pgf@circ@res@step = \ctikzvalof{bipoles/bidirectionaldiode/diode width right}\pgf@circ@res@right

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
    \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@step}{0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
    \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@other}{-0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

    \pgf@circ@draworfill

    \pgfsetlinewidth{\pgfstartlinewidth}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}

    \pgfusepath{draw}
}

%% Full bidirectionaldiode
\pgfcircdeclarebipolescaled{diodes}
{}
{\ctikzvalof{bipoles/bidirectionaldiode/height}}
{fullbidirectionaldiode}
{\ctikzvalof{bipoles/bidirectionaldiode/height}}
{\ctikzvalof{bipoles/bidirectionaldiode/width}}
{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgf@circ@res@other = \ctikzvalof{bipoles/bidirectionaldiode/diode width left}\pgf@circ@res@left
    \pgf@circ@res@step = \ctikzvalof{bipoles/bidirectionaldiode/diode width right}\pgf@circ@res@right

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
    \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@step}{0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
    \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@other}{-0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

    \pgf@circ@fill@strokecolor
    \pgfusepath{draw, fill}

    \pgfsetlinewidth{\pgfstartlinewidth}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}

    \pgfusepath{draw}
}

%%% Thyristors in general


\def\pgfcircdeclarethyristor#1#2#3#4{%name, fill (0-> black; 1-empty), gate position (1: catode, -1: anode), extra code
    \pgfcircdeclarebipolescaled{diodes}
    {
        \savedmacro{\gatekink}{\edef\gatekink{\ctikzvalof{tripoles/thyristor/gate kink}}}
        \anchor{gate}{\northeast\pgf@x=\gatekink\pgf@x\pgf@x=#3\pgf@x}
        \anchor{G}{\northeast\pgf@x=\gatekink\pgf@x\pgf@x=#3\pgf@x}
        \anchor{anode}{\southwest\pgf@y=0cm}
        \anchor{cathode}{\northeast\pgf@y=0cm }
    }
    {\ctikzvalof{tripoles/thyristor/height 2}}
    {#1}
    {\ctikzvalof{tripoles/thyristor/height}}
    {\ctikzvalof{tripoles/thyristor/width}}
    {
        \pgf@circ@res@other = \ctikzvalof{tripoles/thyristor/diode width left}\pgf@circ@res@left
        \pgf@circ@res@step = \ctikzvalof{tripoles/thyristor/diode width right}\pgf@circ@res@right

        \pgfscope
            % draw the thick parts here (shifted horizontally)
            \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
            % draw the basic triangle
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}

            \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
            \pgfpathclose
            \ifnum#2=0\relax
                \pgf@circ@fill@strokecolor
                \pgfusepath{draw,fill}
            \else
                \pgf@circ@draworfill
            \fi
            % draw the vertical bar
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@down}}
            \pgfusepath{draw}
        \endpgfscope

        % back to normal linewidth
        % stroke if needed
        \ifpgf@circuit@bipole@strokedsymbol
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
            \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}}
            \pgfusepath{draw}
        \fi

        % draw the gate thing;
        #4%

        % draw the leads in/out
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}

        \pgfusepath{draw}
    }
}

\def\pgfcirc@thyristor@simplegate{%
    \pgfpathmoveto{\pgfpoint
        {\pgf@circ@res@step}
        {\ctikzvalof{tripoles/thyristor/gate height}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\ctikzvalof{tripoles/thyristor/diode height}\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\pgf@circ@res@up}
    }
    \pgfusepath{draw}
}

%% Black thyristor
\pgfcircdeclarethyristor{fullthyristor}{0}{1}{\pgfcirc@thyristor@simplegate}
%% Empty thyristor
\pgfcircdeclarethyristor{emptythyristor}{1}{1}{\pgfcirc@thyristor@simplegate}
%% black and empty GTO (standard: double line symbol, no arrow)

\def\pgfcirc@doublegate@gto@add{
    % connection to gate terminal
    \pgfpathmoveto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up -
        \ctikzvalof{tripoles/thyristor/gto space down}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\pgf@circ@res@up}
    }
    \pgfusepath{draw}
    \pgfscope
    \pgfcirc@set@arrows{gto gate}{}{}
    % \pgfsetarrowsstart{latexslim}
    % first (lower) gto line: from body to gate
    \pgfpathmoveto{\pgfpoint
        {\pgf@circ@res@step}
        {(\ctikzvalof{tripoles/thyristor/gate height}-\ctikzvalof{tripoles/thyristor/gto space down})
            *\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up -
        \ctikzvalof{tripoles/thyristor/gto space down}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfusepath{draw}
    % second (higher) gto line: from gate to body
    \pgfpathmoveto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up +
        \ctikzvalof{tripoles/thyristor/gto space up}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\pgf@circ@res@step}
        {(\ctikzvalof{tripoles/thyristor/gate height}+\ctikzvalof{tripoles/thyristor/gto space up})
            *\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfusepath{draw}
    \endpgfscope
}
\pgfcircdeclarethyristor{fullgto}{0}{1}{\pgfcirc@doublegate@gto@add}
\pgfcircdeclarethyristor{emptygto}{1}{1}{\pgfcirc@doublegate@gto@add}

\def\pgfcirc@bargate@gto@add{%
    \pgfpathmoveto{\pgfpoint
        {\pgf@circ@res@step}
        {\ctikzvalof{tripoles/thyristor/gate height}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\ctikzvalof{tripoles/thyristor/diode height}\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@right}
        {\pgf@circ@res@up}
    }
    % draw bar line.
    \pgfpathmoveto{\pgfpoint
        {(\ctikzvalof{tripoles/thyristor/gate kink}-\ctikzvalof{tripoles/thyristor/gto bar width})*\pgf@circ@res@right}
        {(1+\ctikzvalof{tripoles/thyristor/diode height})*0.5*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {(\ctikzvalof{tripoles/thyristor/gate kink}+\ctikzvalof{tripoles/thyristor/gto bar width})*\pgf@circ@res@right}
        {(1+\ctikzvalof{tripoles/thyristor/diode height})*0.5*\pgf@circ@res@up}
    }
    \pgfusepath{draw}
}

\pgfcircdeclarethyristor{fullgtobar}{0}{1}{\pgfcirc@bargate@gto@add}
\pgfcircdeclarethyristor{emptygtobar}{1}{1}{\pgfcirc@bargate@gto@add}

%% Thyristors with anode-connected gate

\def\pgfcirc@thyristor@anodegate{%
    \pgfpathmoveto{\pgfpoint
        {\pgf@circ@res@other}
        {\ctikzvalof{tripoles/thyristor/gate height}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@left}
        {\ctikzvalof{tripoles/thyristor/diode height}\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@left}
        {\pgf@circ@res@up}
    }
    \pgfusepath{draw}
}

%% Black PUT
\pgfcircdeclarethyristor{fullput}{0}{-1}{\pgfcirc@thyristor@anodegate}
%% Empty PUT
\pgfcircdeclarethyristor{emptyput}{1}{-1}{\pgfcirc@thyristor@anodegate}
%% black and empty GTO (standard: double line symbol, no arrow)

\def\pgfcirc@anodebargate@gto@add{%
    \pgfpathmoveto{\pgfpoint
        {\pgf@circ@res@other}
        {\ctikzvalof{tripoles/thyristor/gate height}*\ctikzvalof{tripoles/thyristor/diode height}*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@left}
        {\ctikzvalof{tripoles/thyristor/diode height}\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {\ctikzvalof{tripoles/thyristor/gate kink}*\pgf@circ@res@left}
        {\pgf@circ@res@up}
    }
    % draw bar line.
    \pgfpathmoveto{\pgfpoint
        {(\ctikzvalof{tripoles/thyristor/gate kink}-\ctikzvalof{tripoles/thyristor/gto bar width})*\pgf@circ@res@left}
        {(1+\ctikzvalof{tripoles/thyristor/diode height})*0.5*\pgf@circ@res@up}
    }
    \pgfpathlineto{\pgfpoint
        {(\ctikzvalof{tripoles/thyristor/gate kink}+\ctikzvalof{tripoles/thyristor/gto bar width})*\pgf@circ@res@left}
        {(1+\ctikzvalof{tripoles/thyristor/diode height})*0.5*\pgf@circ@res@up}
    }
    \pgfusepath{draw}
}

\pgfcircdeclarethyristor{fullagtobar}{0}{-1}{\pgfcirc@anodebargate@gto@add}
\pgfcircdeclarethyristor{emptyagtobar}{1}{-1}{\pgfcirc@anodebargate@gto@add}

% Triacs

\def\pgfcircdeclaretriac#1#2{%name, fill (0-> black; 1-empty)
    \pgfcircdeclarebipolescaled{diodes}
    {
        \savedmacro{\gatekink}{\edef\gatekink{\ctikzvalof{tripoles/triac/gate kink}}}
        \anchor{gate}{\northeast\pgf@x=\gatekink\pgf@x}
        \anchor{G}{\northeast\pgf@x=\gatekink\pgf@x}
        \anchor{anode}{\southwest\pgf@y=0cm}
        \anchor{cathode}{\northeast\pgf@y=0cm }
    }
    {\ctikzvalof{tripoles/triac/height}}
    {#1}
    {\ctikzvalof{tripoles/triac/height}}
    {\ctikzvalof{tripoles/triac/width}}
    {
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

        \pgf@circ@res@other = \ctikzvalof{tripoles/triac/diode width left}\pgf@circ@res@left
        \pgf@circ@res@step = \ctikzvalof{tripoles/triac/diode width right}\pgf@circ@res@right

        % diodes forms
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
        \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@step}{0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfpathlineto{\pgfpoint{0.95\pgf@circ@res@other}{-0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}}

        \ifnum#2=0\relax
            \pgf@circ@fill@strokecolor
            \pgfusepath{draw,fill}
        \else
            \pgf@circ@draworfill
        \fi

        \pgfsetlinewidth{\pgfstartlinewidth}

        % draw gate
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{-0.707*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
        \pgfpathlineto{\pgfpoint
            {\ctikzvalof{tripoles/triac/gate kink}*\pgf@circ@res@right}
            {-1.414*(\pgf@circ@res@other-\pgf@circ@res@step)}} % sqrt(1/2)
        \pgfpathlineto{\pgfpoint{\ctikzvalof{tripoles/triac/gate kink}*\pgf@circ@res@right}{\pgf@circ@res@up}} % sqrt(1/2)

        % draw leads
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@other}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}

        \pgfusepath{draw}

    }
}

\pgfcircdeclaretriac{fulltriac}{0}
\pgfcircdeclaretriac{emptytriac}{1}

% end of shape definitions for diodes%>>>

%% Paths definitions for Diodes%<<<

\def\pgfcirc@tmp@generatediodes#1#2{
    \pgfcirc@activate@bipole{l}{#1diode}{#1diode}{#1 diode}
    \pgfcirc@style@to@style{#1 diode}{D#2}
    \pgfcirc@activate@bipole{l}{#1zdiode}{#1zdiode}{#1 Zener diode}
    \pgfcirc@style@to@style{#1 Zener diode}{zD#2}
    \pgfcirc@activate@bipole{l}{#1zzdiode}{#1zzdiode}{#1 ZZener diode}
    \pgfcirc@style@to@style{#1 ZZener diode}{zzD#2}
    \pgfcirc@activate@bipole{l}{#1sdiode}{#1sdiode}{#1 Schottky diode}
    \pgfcirc@style@to@style{#1 Schottky diode}{sD#2}
    \pgfcirc@activate@bipole{l}{#1tdiode}{#1tdiode}{#1 tunnel diode}
    \pgfcirc@style@to@style{#1 tunnel diode}{tD#2}
    \pgfcirc@activate@bipole{l}{#1lediode}{#1lediode}{#1 led}
    \pgfcirc@style@to@style{#1 led}{leD#2}
    \pgfcirc@activate@bipole{l}{#1laserdiode}{#1laserdiode}{#1 laser diode}
    \pgfcirc@style@to@style{#1 laser diode}{lasD#2}
    \pgfcirc@activate@bipole{l}{#1pdiode}{#1pdiode}{#1 photodiode}
    \pgfcirc@style@to@style{#1 photodiode}{pD#2}
    \pgfcirc@activate@bipole{l}{#1varcap}{#1varcap}{#1 varcap}
    \pgfcirc@style@to@style{#1 varcap}{VC#2}
    \pgfcirc@activate@bipole{l}{#1tvsdiode}{#1tvsdiode}{#1 TVS diode}
    \pgfcirc@style@to@style{#1 TVS diode}{tvsD#2}
    \pgfcirc@activate@bipole{l}{#1shdiode}{#1shdiode}{#1 Shockley diode}
    \pgfcirc@style@to@style{#1 Shockley diode}{shD#2}
    \pgfcirc@activate@bipole{l}{#1bidirectionaldiode}{#1bidirectionaldiode}{#1 bidirectionaldiode}
    \pgfcirc@style@to@style{#1 bidirectionaldiode}{biD#2}
    \pgfcirc@activate@bipole{l}{#1thyristor}{#1thyristor}{#1 thyristor}
    \pgfcirc@style@to@style{#1 thyristor}{Ty#2}
    \pgfcirc@activate@bipole{l}{#1put}{#1put}{#1 put}
    \pgfcirc@style@to@style{#1 put}{PUT#2}
    \pgfcirc@activate@bipole{l}{#1gto}{#1gto}{#1 gto}
    \pgfcirc@style@to@style{#1 gto}{GTO#2}
    \pgfcirc@activate@bipole{l}{#1gtobar}{#1gtobar}{#1 gtobar}
    \pgfcirc@style@to@style{#1 gtobar}{GTOb#2}
    \pgfcirc@activate@bipole{l}{#1agtobar}{#1agtobar}{#1 agtobar}
    \pgfcirc@style@to@style{#1 agtobar}{aGTOb#2}
    \pgfcirc@activate@bipole{l}{#1triac}{#1triac}{#1 triac}
    \pgfcirc@style@to@style{#1 triac}{Tr#2}
}
\pgfcirc@tmp@generatediodes{full}{*}
\pgfcirc@tmp@generatediodes{empty}{o}
\def\pgfcirc@tmp@generatestrokeddiodes#1#2{
    \pgfcirc@node@to@style{l}{emptydiode}{#1 diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 diode}{D#2}
    \pgfcirc@node@to@style{l}{emptyzdiode}{#1 Zener diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 Zener diode}{zD#2}
    \pgfcirc@node@to@style{l}{emptyzzdiode}{#1 ZZener diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 ZZener diode}{zzD#2}
    \pgfcirc@node@to@style{l}{emptysdiode}{#1 Schottky diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 Schottky diode}{sD#2}
    \pgfcirc@node@to@style{l}{emptytdiode}{#1 tunnel diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 tunnel diode}{tD#2}
    \pgfcirc@node@to@style{l}{emptylediode}{#1 led}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 led}{leD#2}
    \pgfcirc@node@to@style{l}{emptylaserdiode}{#1 laser diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 laser diode}{lasD#2}
    \pgfcirc@node@to@style{l}{emptypdiode}{#1 photodiode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 photodiode}{pD#2}
    \pgfcirc@node@to@style{l}{emptyvarcap}{#1 varcap}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 varcap}{VC#2}
    \pgfcirc@node@to@style{l}{emptytvsdiode}{#1 TVS diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 TVS diode}{tvsD#2}
    \pgfcirc@node@to@style{l}{emptyshdiode}{#1 Shockley diode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 Shockley diode}{shD#2}
    \pgfcirc@node@to@style{l}{emptybidirectionaldiode}{#1 bidirectionaldiode}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 bidirectionaldiode}{biD#2}
    \pgfcirc@node@to@style{l}{emptythyristor}{#1 thyristor}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 thyristor}{Ty#2}
    \pgfcirc@node@to@style{l}{emptyput}{#1 put}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 put}{PUT#2}
    \pgfcirc@node@to@style{l}{emptygto}{#1 gto}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 gto}{GTO#2}
    \pgfcirc@node@to@style{l}{emptygtobar}{#1 gtobar}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 gtobar}{GTOb#2}
    \pgfcirc@node@to@style{l}{emptyagtobar}{#1 agtobar}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 agtobar}{aGTOb#2}
    \pgfcirc@node@to@style{l}{emptytriac}{#1 triac}{\circuitikzbasekey/bipole/is strokedsymbol=true}
    \pgfcirc@style@to@style{#1 triac}{Tr#2}
}
\pgfcirc@tmp@generatestrokeddiodes{stroke}{-}
\def\pgfcircdiodestylemacro{\ifpgf@circuit@strokediode stroke \else\ifpgf@circuit@fulldiode full \else empty \fi\fi}
% these are auto-switching styles
\pgfcirc@style@to@style{\pgfcircdiodestylemacro diode}{diode}
\pgfcirc@style@to@style{diode}{D}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro Zener diode}{Zener diode}
\pgfcirc@style@to@style{Zener diode}{zD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro ZZener diode}{ZZener diode}
\pgfcirc@style@to@style{ZZener diode}{zzD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro Schottky diode}{Schottky diode}
\pgfcirc@style@to@style{Schottky diode}{sD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro tunnel diode}{tunnel diode}
\pgfcirc@style@to@style{tunnel diode}{tD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro led}{led}
\pgfcirc@style@to@style{led}{leD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro photodiode}{photodiode}
\pgfcirc@style@to@style{photodiode}{pD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro laser diode}{laser diode}
\pgfcirc@style@to@style{laser diode}{lasD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro varcap}{varcap}
\pgfcirc@style@to@style{varcap}{VC}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro TVS diode}{TVS diode}
\pgfcirc@style@to@style{TVS diode}{tvsD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro Shockley diode}{Shockley diode}
\pgfcirc@style@to@style{Shockley diode}{shD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro bidirectionaldiode}{bidirectionaldiode}
\pgfcirc@style@to@style{bidirectionaldiode}{biD}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro thyristor}{thyristor}
\pgfcirc@style@to@style{thyristor}{Ty}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro put}{put}
\pgfcirc@style@to@style{put}{PUT}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro gto}{gto}
\pgfcirc@style@to@style{gto}{GTO}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro gtobar}{gtobar}
\pgfcirc@style@to@style{gtobar}{GTOb}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro agtobar}{agtobar}
\pgfcirc@style@to@style{agtobar}{aGTOb}
\pgfcirc@style@to@style{\pgfcircdiodestylemacro triac}{triac}
\pgfcirc@style@to@style{triac}{Tr}
% %>>>

%%%%%%%%%%%%%
%% switches, buttons and jumpers
%%%%%%%%%%%%%

%% Definitions for switches%<<<1

\ctikzset{bipoles/spst/height/.initial=.35}
\ctikzset{bipoles/spst/width/.initial=.35}
\ctikzset{bipoles/spst/depth/.initial=.2}
\ctikzset{bipoles/nos/height/.initial=.3}
\ctikzset{bipoles/nos/width/.initial=.35}
\ctikzset{bipoles/nos/depth/.initial=.2}
\ctikzset{bipoles/ncs/height/.initial=.35}
\ctikzset{bipoles/ncs/width/.initial=.35}
\ctikzset{bipoles/ncs/depth/.initial=.2}
\ctikzset{bipoles/pushbutton/height/.initial=.5}
\ctikzset{bipoles/pushbutton/height 2/.initial=.2}
\ctikzset{bipoles/pushbutton/width/.initial=.50}
%%% reed switch
\ctikzset{bipoles/reed/height/.initial=.4}
\ctikzset{bipoles/reed/width/.initial=.8}% 0.35 in nos
\ctikzset{bipoles/reed/depth/.initial=.4}
%% Cute switches
\ctikzset{bipoles/cuteswitch/shape/.initial={ocirc}}
\ctikzset{bipoles/cuteswitch/height/.initial=.6}
\ctikzset{bipoles/cuteswitch/height 2/.initial=.2}
\ctikzset{bipoles/cuteswitch/width/.initial=.50}
\ctikzset{bipoles/cuteswitch/thickness/.initial=1}

\ctikzset{tripoles/spdt/width/.initial=.85}
\ctikzset{tripoles/spdt/height/.initial=.45}
\ctikzset{tripoles/spdt/margin/.initial=.45}

\ctikzset{tripoles/toggleswitch/height/.initial=.8}
\ctikzset{tripoles/toggleswitch/height 2/.initial=.0}
\ctikzset{tripoles/toggleswitch/width/.initial=.80}
%% arrow configurability
\ctikzset{switch arrows/.is family}
\ctikzset{switch arrows/relative thickness/.initial=1}
\ctikzset{switch arrows/color/.initial=default}
\ctikzset{switch arrows/dash/.initial=default}
\def\pgf@circ@set@switcharrow@style{%
    % You *must* be sure that this is called inside a \pgfscope!
    \pgfsetlinewidth{\ctikzvalof{switch arrows/relative thickness}\pgflinewidth}
    \pgf@circ@subset@color@dash{switch arrows}
    \pgfcirc@set@arrows{switch}{}{latexslim}
    }
%%>>>

%% Shapes Node for bipoles switches and similar things%<<<
%% (Closing) SPST
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/spst/depth}}
{cspst}
{\ctikzvalof{bipoles/spst/height}}
{\ctikzvalof{bipoles/spst/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{90}{1.2\pgf@circ@res@right}}
        \pgfpatharc{90}{-20}{1.2\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Opening SPST
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/spst/depth}}
{ospst}
{\ctikzvalof{bipoles/spst/height}}
{\ctikzvalof{bipoles/spst/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{-10}{1.2\pgf@circ@res@right}}
        \pgfpatharc{-10}{90}{1.2\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Normal open Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/nos/depth}}
{nos}
{\ctikzvalof{bipoles/nos/height}}
{\ctikzvalof{bipoles/nos/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfsetbuttcap
    \pgfusepath{draw}
}

%% Normal closed Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/ncs/depth}}
{ncs}
{\ctikzvalof{bipoles/ncs/height}}
{\ctikzvalof{bipoles/ncs/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
}

% Opening normal closed Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/ncs/depth}}
{oncs}
{\ctikzvalof{bipoles/ncs/height}}
{\ctikzvalof{bipoles/ncs/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{-10}{.9\pgf@circ@res@right}}
        \pgfpatharc{-10}{95}{.9\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Closing normal closed Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/ncs/depth}}
{cncs}
{\ctikzvalof{bipoles/ncs/height}}
{\ctikzvalof{bipoles/ncs/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{90}{.9\pgf@circ@res@right}}
        \pgfpatharc{90}{-35}{.9\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Opening normal open Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/ncs/depth}}
{onos}
{\ctikzvalof{bipoles/ncs/height}}
{\ctikzvalof{bipoles/ncs/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{.4\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{-10}{.9\pgf@circ@res@right}}
        \pgfpatharc{-10}{95}{.9\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Closing normal open Switch
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/ncs/depth}}
{cnos}
{\ctikzvalof{bipoles/ncs/height}}
{\ctikzvalof{bipoles/ncs/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{.4\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathmoveto{\pgfpointpolar{90}{.9\pgf@circ@res@right}}
        \pgfpatharc{90}{-35}{.9\pgf@circ@res@right}
        \pgf@circ@set@switcharrow@style
        \pgfsetbeveljoin
        \pgfusepath{draw}
    \endpgfscope
}

%% Push Button
\pgfcircdeclarebipolescaled{switches}
{
    \anchor{tip}{\northeast\pgf@x=0pt\relax}
}
{\ctikzvalof{bipoles/pushbutton/height 2}}
{pushbutton}
{\ctikzvalof{bipoles/pushbutton/height}}
{\ctikzvalof{bipoles/pushbutton/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{.5\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{0}{.5\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@up}}
    \pgfusepath{draw}

    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
    \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}

%% Normally closed Push Button
\pgfcircdeclarebipolescaled{switches}
{
    \anchor{tip}{\northeast\pgf@x=0pt\relax}
}
{\ctikzvalof{bipoles/pushbutton/height 2}}
{ncpushbutton}
{\ctikzvalof{bipoles/pushbutton/height}}
{\ctikzvalof{bipoles/pushbutton/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
    % Warning, if the nodes will have a class, we have to touch this.
    \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp}}
    \pgfpathmoveto{\pgfpoint{0}{-\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@up}}
    \pgfusepath{draw}
    %
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
    \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}
%% Push Button (normally closed but now open :-) see
%% https://github.com/circuitikz/circuitikz/issues/128#issuecomment-731771299
\pgfcircdeclarebipolescaled{switches}
{
    \anchor{tip}{
        \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
        \northeast\divide\pgf@y by 2\advance\pgf@y by \pgf@circ@res@temp
        \pgf@x=0pt\relax
    }
}
{\ctikzvalof{bipoles/pushbutton/height 2}}
{pushbuttonc}
{\ctikzvalof{bipoles/pushbutton/height}}
{\ctikzvalof{bipoles/pushbutton/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp}}
    \pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@up/2+\pgf@circ@res@temp}}
    \pgfusepath{draw}

    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
    \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}

%% Normally closed Push Button now open
\pgfcircdeclarebipolescaled{switches}
{
    \anchor{tip}{
        \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
        \northeast\divide\pgf@y by 2\advance\pgf@y by \pgf@circ@res@temp
        \pgf@x=0pt\relax
    }
}
{\ctikzvalof{bipoles/pushbutton/height 2}}
{ncpushbuttono}
{\ctikzvalof{bipoles/pushbutton/height}}
{\ctikzvalof{bipoles/pushbutton/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
    % Warning, if the nodes will have a class, we have to touch this.
    \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up/2}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@up/2}}
    \pgfpathmoveto{\pgfpoint{0}{-\pgf@circ@res@up/2}}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@up/2+\pgf@circ@res@temp}}
    \pgfusepath{draw}
    %
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
    \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
    \pgfnode{ocirc}{center}{}{}{\pgfusepath{draw}}
}
%%% reed switches
\pgfcircdeclarebipolescaled{switches}
{}
{\ctikzvalof{bipoles/reed/depth}}
{reed}
{\ctikzvalof{bipoles/reed/height}}
{\ctikzvalof{bipoles/reed/width}}
{
    % this is designed to be the same as a "nos".
    \pgfmathsetmacro{\@@tmpx}{0.9*\ctikzvalof{bipoles/nos/width}/\ctikzvalof{bipoles/reed/width}}
    \pgfmathsetmacro{\@@tmpy}{\ctikzvalof{bipoles/nos/height}/\ctikzvalof{bipoles/reed/height}}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        % eclosure
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@up}{\pgf@circ@res@up}}
        \pgfpatharc{90}{-90}{\pgf@circ@res@up}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@up}{-\pgf@circ@res@up}}
        \pgfpatharc{270}{90}{\pgf@circ@res@up}
        \pgfpathclose
        \pgf@circ@draworfill
        % switch
        \pgfpathmoveto{\pgfpoint{\@@tmpx\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{\@@tmpx\pgf@circ@res@right}{\@@tmpy\pgf@circ@res@up}}
        % connection lines
        \pgfsetbuttcap
        \pgfusepath{draw}
    \endpgfscope
    % connection lines
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\@@tmpx\pgf@circ@res@left}{0pt}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\@@tmpx\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}

% cute switch "to" shapes help function
% #1 -> name
% #2 -> barposition
% #3 -> arrowcode
\long\def\pgfcircdeclarecutesw#1#2#3{
    \pgfcircdeclarebipolescaled{switches}
    {
        \savedanchor\midlever{
            % these values are calculated when we create the definition of the shape.
            \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
            \pgf@y=\ctikzvalof{bipoles/cuteswitch/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@scaled@Rlen
            \pgf@circ@res@temp=\ctikzvalof{bipoles/cuteswitch/thickness}\pgf@circ@res@temp
            \pgf@circ@res@down = -.5\pgf@y
            \pgf@circ@res@up = .5\pgf@y
            \pgfextracty{\pgf@circ@res@other}{#2}
            \pgf@x=0pt
            \pgf@y=.5\pgf@circ@res@other
        }
        % radius of the connector
        % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
        % If cnnecting nodes are scaled, we have to modify this
        \saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}}
        % shapename
        \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
        % shape type
        \savedmacro{\cshape}{\def\cshape{\ctikzvalof{bipoles/cuteswitch/shape}}}
        % mid of the lever, to stack switches
        \anchor{mid}{\midlever}
        \anchor{cout}{\northeast \pgf@y=0cm}
        \anchor{cin}{\southwest\pgf@y=0cm}
        \anchor{out}{\northeast \pgf@y=0cm\advance\pgf@x by \radius}
        \anchor{in}{\southwest\pgf@y=0cm\advance\pgf@x by -\radius}
    }
    {\ctikzvalof{bipoles/cuteswitch/height 2}}
    {#1}
    {\ctikzvalof{bipoles/cuteswitch/height}}
    {\ctikzvalof{bipoles/cuteswitch/width}}{
        \pgfscope
        % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
        % If connecting nodes are scaled, we have to modify this
        \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@Rlen
        \pgf@circ@res@temp=\ctikzvalof{bipoles/cuteswitch/thickness}\pgf@circ@res@temp
        \pgfsetlinewidth{2\pgf@circ@res@temp}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{#2}
        \pgfsetroundcap\pgfusepath{draw}
        \endpgfscope
        \pgfscope % arrow
            \pgf@circ@fill@strokecolor
            #3%
        \endpgfscope
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{draw}}
        \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-out}{\pgfusepath{draw}}
    }
}

%% closed cute switch
\pgfcircdeclarecutesw{cuteclosedswitch}
    {\pgfpoint{\pgf@circ@res@right}{1.5\pgf@circ@res@temp}}
    {}

%% open cute switch
\pgfcircdeclarecutesw{cuteopenswitch}
    {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    {}

%% closing cute switch
\pgfcircdeclarecutesw{cuteclosingswitch}
    {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    {
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node
    \pgfpathmoveto{\pgfpointpolar{70}{1.2\pgf@circ@res@right}}
    \pgfpatharc{70}{-10}{1.2\pgf@circ@res@right}
    \pgf@circ@set@switcharrow@style
    \pgfusepath{draw}
    }

%% opening cute switch
\pgfcircdeclarecutesw{cuteopeningswitch}
    {\pgfpoint{\pgf@circ@res@right}{1.5\pgf@circ@res@temp}}
    {
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node
    \pgfpathmoveto{\pgfpointpolar{-10}{1.2\pgf@circ@res@right}}
    \pgfpatharc{-10}{60}{1.2\pgf@circ@res@right}
    \pgf@circ@set@switcharrow@style
    \pgfusepath{draw}
    }

\pgfcircdeclarebipole{
    \anchor{out 1}{
        \northeast
        \pgf@y=0cm
    }
    \anchor{out 2}{
        \northeast
        \pgf@y=.8\pgf@y
    }
}
{\ctikzvalof{tripoles/toggleswitch/height 2}}
{toggleswitch}
{\ctikzvalof{tripoles/toggleswitch/height}}
{\ctikzvalof{tripoles/toggleswitch/width}}
{

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.3\pgf@circ@res@left}{0pt}}
    \pgfusepath{draw}
    \pgfscope
        \pgfpathmoveto{\pgfpoint{.3\pgf@circ@res@left}{0pt}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{.5\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{.5\pgf@circ@res@right}{0}}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{.8\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.5\pgf@circ@res@right}{.8\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.5\pgf@circ@res@right}{.15\pgf@circ@res@up}}
    \pgfusepath{draw}


    \pgfpathmoveto{\pgfpoint{.2\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfusepath{draw}

    \pgfsetdash{{.08\pgf@circ@res@up}{.04\pgf@circ@res@up}{.7\pgf@circ@res@up}{.04\pgf@circ@res@up}{.8\pgf@circ@res@up}}{0cm}
    \pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0}{.8\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@left}{.6\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0}{.4\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0}{.2\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetdash{}{0cm}
}

% %>>>

%% Shape nodes for switches (non-bipoles)%<<<

%%%%%%%%%%%%%
%% switches
%%%%%%%%%%%%%

% Legacy spdt
\pgfdeclareshape{spdt}{
    \savedmacro{\ctikzclass}{\edef\ctikzclass{switches}}
    \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
    \savedanchor\northwest{%
        \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
        \pgf@y=\ctikzvalof{tripoles/spdt/height}\pgf@circ@scaled@Rlen
        \pgf@y=.5\pgf@y
        \pgf@x=-\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen
        \pgf@x=.5\pgf@x
    }
    \anchor{left}{%
        \northwest
        \pgf@y=0pt
    }
    \anchor{in}{
        \northwest
        \pgf@y=0pt
    }
    \anchor{out 1}{
        \northwest
        \pgf@x=-\pgf@x
    }
    \anchor{out 2}{
        \northwest
        \pgf@x=-\pgf@x
        \pgf@y=-\pgf@y
    }
    \anchor{center}{
        \pgf@y=0pt
        \pgf@x=0pt
    }
    \anchor{east}{
        \northwest
        \pgf@y=0pt
        \pgf@x=-\pgf@x
    }
    \anchor{west}{
        \northwest
        \pgf@y=0pt
    }
    \anchor{south}{
        \northwest
        \pgf@x=0pt
        \pgf@y=-\pgf@y
    }
    \anchor{north}{
        \northwest
        \pgf@x=0pt
    }
    \anchor{south west}{
        \northwest
        \pgf@y=-\pgf@y
    }
    \anchor{north east}{
        \northwest
        \pgf@x=-\pgf@x
    }
    \anchor{north west}{
        \northwest
    }
    \anchor{south east}{
        \northwest
        \pgf@x=-\pgf@x
        \pgf@y=-\pgf@y
    }
    \pgf@circ@draw@component{
        \pgf@circ@setcolor

        \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
        \pgf@circ@res@other = \ctikzvalof{tripoles/spdt/margin}\pgf@circ@res@left


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

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}}

        \pgfusepath{draw}

        \pgfscope
            \pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
            \pgfnode{ocirc}{center}{}{spdt1}{\pgfusepath{stroke}}
        \endpgfscope
        \pgfscope
            \pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}
            \pgfnode{ocirc}{center}{}{}{\pgfusepath{stroke}}
        \endpgfscope
        \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@other}{0pt}}
            \pgfnode{ocirc}{center}{}{spdt2}{\pgfusepath{stroke}}
        \endpgfscope

        \pgfscope
            \pgfpathmoveto{\pgfpointshapeborder{spdt2}{\pgfpointorigin}}
            \pgfpathlineto{
                \pgfpointadd{\pgfpointshapeborder{spdt1}{\pgfpoint{-\pgf@circ@res@other}{-100pt}}}
                {\pgfpoint{-.05\pgf@circ@res@up}{-.05\pgf@circ@res@up}}
            }
            \pgf@circ@setlinewidth{tripoles}{\pgflinewidth}
            \pgfusepath{draw}
        \endpgfscope
    }
}


% cute switch "node" shapes, matching with cute "to" shapes
% #1 -> name
% #2 -> barposition
% #3 -> arrowcode
\long\def\pgfcircdeclarecutespdt#1#2#3{
    \pgfdeclareshape{#1}
    {
        \savedmacro{\ctikzclass}{\edef\ctikzclass{switches}}
        \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
        \savedanchor\northwest{%
            \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
            \pgf@y=\ctikzvalof{bipoles/cuteswitch/height}\pgf@circ@scaled@Rlen
            \pgf@y=.5\pgf@y
            \pgf@x=-\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen
            \pgf@x=.25\pgf@x
        }
        \savedanchor\midlever{
            % these values are calculated when we create the definition of the shape.
            \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
            \pgf@y=\ctikzvalof{bipoles/cuteswitch/height}\pgf@circ@scaled@Rlen
            \pgf@circ@res@temp=\ctikzvalof{nodes width}\pgf@circ@scaled@Rlen
            \pgf@circ@res@temp=\ctikzvalof{bipoles/cuteswitch/thickness}\pgf@circ@res@temp
            \pgf@circ@res@down = -.5\pgf@y
            \pgf@circ@res@up = .5\pgf@y
            \pgfextracty{\pgf@circ@res@other}{#2}
            \pgf@x=0pt
            \pgf@y=.5\pgf@circ@res@other
        }
        % radius of the connector
        % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
        \saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}}
        % shapename
        \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
        % shape type
        \savedmacro{\cshape}{\def\cshape{\ctikzvalof{bipoles/cuteswitch/shape}}}
        % mid of the lever, to stack switches
        \anchor{mid}{\midlever}
        % center anchors
        \anchor{cin}{ \northwest \pgf@y=0pt}
        \anchor{cout 1}{ \northwest \pgf@x=-\pgf@x }
        \anchor{cout 2}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
        % horizontal angles
        \anchor{in}{ \northwest \pgf@y=0pt\advance\pgf@x by -\radius}
        \anchor{out 1}{ \northwest \pgf@x=-\pgf@x \advance\pgf@x by \radius}
        \anchor{out 2}{ \northwest \pgf@x=-\pgf@x \advance\pgf@x by \radius \pgf@y=-\pgf@y }

        \anchor{center}{ \pgf@y=0pt \pgf@x=0pt }
        \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x  }
        \anchor{west}{ \northwest \pgf@y=0pt }
        \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y }
        \anchor{north}{ \northwest \pgf@x=0pt }
        \anchor{south west}{ \northwest \pgf@y=-\pgf@y }
        \anchor{north east}{ \northwest \pgf@x=-\pgf@x }
        \anchor{north west}{ \northwest }
        \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y }

        \pgf@circ@draw@component{
            \pgf@circ@setcolor
            \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
            % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
            \pgf@circ@res@temp=\radius\relax
            \pgf@circ@res@temp=\ctikzvalof{bipoles/cuteswitch/thickness}\pgf@circ@res@temp
            \pgfsetlinewidth{2\pgf@circ@res@temp}
            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfpathlineto{#2}
            \pgfsetroundcap\pgfusepath{draw}
            \endpgfscope
            \pgfscope % arrow
                \pgf@circ@fill@strokecolor
                #3%
            \endpgfscope
            % terminals
            \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgfnode{\cshape}{center}{}{\thisshape-out 1}{\pgfusepath{stroke}}
            \endpgfscope
            \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
            \pgfnode{\cshape}{center}{}{\thisshape-out 2}{\pgfusepath{stroke}}
            \endpgfscope
            \pgfscope
            \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{stroke}}
            \endpgfscope

        }
    }
}

\pgfcircdeclarecutespdt{cute spdt up}
{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up-1.5\pgf@circ@res@temp}}
{}

\pgfcircdeclarecutespdt{cute spdt mid}
{\pgfpoint{\pgf@circ@res@right}{0pt}}
{}

\pgfcircdeclarecutespdt{cute spdt down}
{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down+1.5\pgf@circ@res@temp}}
{}

\pgfcircdeclarecutespdt{cute spdt up arrow}
{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up-1.5\pgf@circ@res@temp}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgflinewidth}
    \pgfsetlinewidth{\ctikzvalof{switch arrows/relative thickness}\pgflinewidth}
    \pgf@circ@subset@color@dash{switch arrows}
    \pgfcirc@set@arrows{switch}{}{latexslim}
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node
    \pgfpathmoveto{\pgfpointpolar{70}{1.5\pgf@circ@res@right}}
    \pgfpatharc{70}{-50}{1.5\pgf@circ@res@right}
    \pgfusepath{draw}
}

\pgfcircdeclarecutespdt{cute spdt mid arrow}
{\pgfpoint{\pgf@circ@res@right}{0pt}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgflinewidth}
    \pgfsetlinewidth{\ctikzvalof{switch arrows/relative thickness}\pgflinewidth}
    \pgf@circ@subset@color@dash{switch arrows}
    \pgfcirc@set@arrows{switch}{latexslim}{latexslim}
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node
    \pgfpathmoveto{\pgfpointpolar{-60}{1.5\pgf@circ@res@right}}
    \pgfpatharc{-60}{60}{1.5\pgf@circ@res@right}
    \pgfusepath{draw}
}

\pgfcircdeclarecutespdt{cute spdt down arrow}
{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down+1.5\pgf@circ@res@temp}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgflinewidth}
    \pgfsetlinewidth{\ctikzvalof{switch arrows/relative thickness}\pgflinewidth}
    \pgf@circ@subset@color@dash{switch arrows}
    \pgfcirc@set@arrows{switch}{}{latexslim}
    \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % in node
    \pgfpathmoveto{\pgfpointpolar{-50}{1.5\pgf@circ@res@right}}
    \pgfpatharc{-50}{70}{1.5\pgf@circ@res@right}
    \pgfusepath{draw}
}
% %>>>

%% Paths Switches and buttons%<<<

\pgfcirc@activate@bipole{l}{cspst}{cspst}{closing switch}
\pgfcirc@style@to@style{closing switch}{switch}
\pgfcirc@style@to@style{closing switch}{cspst}
\pgfcirc@style@to@style{switch}{spst}
\pgfcirc@activate@bipole{l}{ospst}{ospst}{opening switch}
\pgfcirc@style@to@style{opening switch}{ospst}

\pgfcirc@activate@bipole@simple{l}{nos}
\pgfcirc@style@to@style{nos}{normal open switch}
\pgfcirc@activate@bipole@simple{l}{ncs}
\pgfcirc@style@to@style{ncs}{normal closed switch}
\pgfcirc@activate@bipole@simple{l}{oncs}
\pgfcirc@style@to@style{oncs}{opening normal closed switch}
\pgfcirc@activate@bipole@simple{l}{cncs}
\pgfcirc@style@to@style{cncs}{closing normal closed switch}
\pgfcirc@activate@bipole@simple{l}{onos}
\pgfcirc@style@to@style{onos}{opening normal open switch}
\pgfcirc@activate@bipole@simple{l}{cnos}
\pgfcirc@style@to@style{cnos}{closing normal open switch}

\pgfcirc@activate@bipole{l}{pushbutton}{pushbutton}{push button}
\pgfcirc@style@to@style{push button}{nopb}
\pgfcirc@style@to@style{push button}{normally open push button}
\pgfcirc@activate@bipole{l}{ncpushbutton}{ncpushbutton}{ncpb}
\pgfcirc@style@to@style{ncpb}{normally closed push button}
\pgfcirc@activate@bipole{l}{pushbuttonc}{pushbuttonc}{nopbc}
\pgfcirc@style@to@style{nopbc}{normally open push button closed}
\pgfcirc@activate@bipole{l}{ncpushbuttono}{ncpushbuttono}{ncpbo}
\pgfcirc@style@to@style{ncpbo}{normally closed push button open}

\pgfcirc@activate@bipole{l}{toggleswitch}{toggleswitch}{toggle switch}
\pgfcirc@activate@bipole@simple{l}{reed}

\pgfcirc@activate@bipole{l}{cuteclosedswitch}{cuteclosedswitch}{cute closed switch}
\pgfcirc@style@to@style{cute closed switch}{ccsw}
\pgfcirc@activate@bipole{l}{cuteopenswitch}{cuteopenswitch}{cute open switch}
\pgfcirc@style@to@style{cute open switch}{cosw}
\pgfcirc@activate@bipole{l}{cuteclosingswitch}{cuteclosingswitch}{cute closing switch}
\pgfcirc@style@to@style{cute closing switch}{ccgsw}
\pgfcirc@activate@bipole{l}{cuteopeningswitch}{cuteopeningswitch}{cute opening switch}
\pgfcirc@style@to@style{cute opening switch}{cogsw}% %>>>

%% Proximity switch auxiliary shapes%<<<
%% proximeter shape, for usage with switches
\ctikzset{proximeter/width/.initial=0.3}
\ctikzset{proximeter/hlines thickness/.initial=0.5}
\ctikzset{proximeter/hlines position/.initial=0.3}
\pgfdeclareshape{proximeter}
{
    \savedmacro{\ctikzclass}{\edef\ctikzclass{switches}}
    \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
    \savedmacro{\hlinepos}{\edef\hlinepos{\ctikzvalof{proximeter/hlines position}}}
    \savedanchor\northeast{%
        \pgfmathsetlength{\pgf@y}{\ctikzvalof{proximeter/width}*\ctikzvalof{\ctikzclass/scale}*\pgf@circ@Rlen}
        \pgf@x=\pgf@y
    }
    \anchor{center}{\pgfpointorigin}
    % geo anchors based on north-east
    \pgfcirc@northeast@symmetric@geoanchors
    \anchor{text}{%
        \northeast
        \pgf@x=\dimexpr -.5\wd\pgfnodeparttextbox\relax
        \advance\pgf@y by .6\ht\pgfnodeparttextbox\relax
    }
    \anchor{hlines ne}{%
        \northeast
        \pgf@y=\hlinepos\pgf@y
        \advance\pgf@x by -\pgf@y
    }
    \anchor{hlines nw}{%
        \northeast
        \pgf@y=\hlinepos\pgf@y
        \advance\pgf@x by -\pgf@y\pgf@x=-\pgf@x
    }
    \anchor{hlines se}{%
        \northeast
        \pgf@y=\hlinepos\pgf@y
        \advance\pgf@x by -\pgf@y
        \pgf@y=-\pgf@y
    }
    \anchor{hlines sw}{%
        \northeast
        \pgf@y=\hlinepos\pgf@y
        \advance\pgf@x by -\pgf@y\pgf@x=-\pgf@x
        \pgf@y=-\pgf@y
    }
    \anchorborder{
        % \typeout{IN\space X:\the\pgf@x\space Y:\the\pgf@y}
        \pgfmathsetmacro{\@@switchx}{ifthenelse(\pgf@x>0,1,-1)}
        \pgfmathsetmacro{\@@switchy}{ifthenelse(\pgf@y>0,1,-1)}
        \pgfmathsetlength{\pgf@xa}{abs(\pgf@x)}
        \pgfmathsetlength{\pgf@ya}{abs(\pgf@y)}
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        % \typeout{MID\space X:\the\pgf@xa\space Y:\the\pgf@ya\space L:\the\pgf@circ@res@up}
        % \typeout{MID\space SX:\@@switchx\space SY:\@@switchy}
        \pgfpointintersectionoflines
            {\pgfpointorigin}{\pgfqpoint{\pgf@xa}{\pgf@ya}}
            {\pgfqpoint{0pt}{\pgf@circ@res@up}}{\pgfqpoint{\pgf@circ@res@up}{0pt}}
        % \typeout{CROSS \space X:\the\pgf@x\space Y:\the\pgf@y}
        \pgf@x=\@@switchx\pgf@x
        \pgf@y=\@@switchy\pgf@y
    }
    \pgf@circ@draw@component{
        \northeast\pgf@circ@res@temp=\pgf@y
        \pgf@circ@setcolor
        \pgf@circ@setlinewidth{tripoles}{\pgflinewidth}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp}{0pt}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@temp}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{0pt}}
        \pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@temp}}
        \pgfpathclose
        \pgf@circ@draworfill
        \pgfsetlinewidth{\ctikzvalof{proximeter/hlines thickness}*\pgflinewidth}
        \pgfmathsetlength{\pgf@circ@res@up}{\hlinepos*\pgf@circ@res@temp}
        \pgfmathsetlength{\pgf@circ@res@right}{\pgf@circ@res@temp-\pgf@circ@res@up}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{-\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@up}}
        \pgfusepath{draw}
    }

}
\pgfcirc@node@to@path{proximeter}{inline proximeter}{}
% %>>>

% jumpers: definitions and code %<<<
% definitons for jumpers
\ctikzset{bipoles/jumper/width/.initial=0.4}
\ctikzset{bipoles/tjumper/width/.initial=0.6}% normally is less than 0.4*2
\ctikzset{tjumper connections/.initial=00}% bare-bare
\ctikzset{bipoles/jumper/height/.initial=0.4}
\ctikzset{bipoles/jumper/depth/.initial=0.1}
\ctikzset{bipoles/jumper/shape/.initial=ocirc}
\ctikzset{bipoles/jumper/curvature/.initial=2}  % curvature of the arc
\ctikzset{bipoles/jumper/open shift/.initial=3} % displacement to open the arc

% jumpers
% simple jumpers
% #1 -> name
% #2 -> height of the link arc (0 means no link, 1 closed, 2 open)
\long\def\pgfcircdeclarejumper#1#2{
    \pgfcircdeclarebipolescaled{switches}
        {
            % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
            \saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}}
            % shapename
            \savedmacro{\thisshape}{\edef\thisshape{\tikz@fig@name}}
            % shape type
            \savedmacro{\cshape}{\edef\cshape{\ctikzvalof{bipoles/jumper/shape}}}
            % arc characteristics (can vary, must be saved...)
            \savedmacro{\curvature}{\edef\curvature{\ctikzvalof{bipoles/jumper/curvature}}}
            \savedmacro{\openshift}{\edef\openshift{\ctikzvalof{bipoles/jumper/open shift}}}
            %
            \anchor{cout}{\northeast \pgf@y=0cm}
            \anchor{cin}{\southwest\pgf@y=0cm}
            \anchor{out}{\northeast \pgf@y=0cm\advance\pgf@x by \radius}
            \anchor{in}{\southwest\pgf@y=0cm\advance\pgf@x by -\radius}
            \anchor{text}{\northeast
                \pgf@x=\dimexpr -.5\wd\pgfnodeparttextbox\relax
                \advance\pgf@y by .6\ht\pgfnodeparttextbox\relax
            }
            \anchor{top arc}{\northeast
                \pgf@circ@res@other=\pgf@x
                \pgf@circ@res@temp=\radius
                \ifnum #2=1 \edef\@@b{1}\else\edef\@@b{\openshift}\fi
                \pgfpointcurveattime{0.5}
                    {\pgfpoint{-0.9\pgf@circ@res@other}{{(\@@b)*\radius}}}
                    {\pgfpoint{-0.5\pgf@circ@res@other}{{(\@@b+\curvature)*\radius}}}
                    {\pgfpoint{0.5\pgf@circ@res@other}{{(\@@b+\curvature)*\radius}}}
                    {\pgfpoint{0.9\pgf@circ@res@other}{{(\@@b)*\radius}}}
            }
        }
        {\ctikzvalof{bipoles/jumper/depth}}
        {#1}
        {\ctikzvalof{bipoles/jumper/height}}
        {\ctikzvalof{bipoles/jumper/width}}{
            %
            \ifnum #2=0 \else
                \ifnum #2=1 \edef\@@b{1}\else\edef\@@b{\openshift}\fi
                \pgfpathmoveto{\pgfpoint{0.9*\pgf@circ@res@left}{(\@@b)*\radius}}
                \pgfpathcurveto
                    {\pgfpoint{.5\pgf@circ@res@left}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{.5\pgf@circ@res@right}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{0.9*\pgf@circ@res@right}{(\@@b)*\radius}}
                \pgfusepath{draw}
            \fi
            \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{draw}}
            \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
            \pgfnode{\cshape}{center}{}{\thisshape-out}{\pgfusepath{draw}}
        }
}
\pgfcircdeclarejumper{bjumper}{0}
\pgfcircdeclarejumper{cjumper}{1}
\pgfcircdeclarejumper{ojumper}{2}
\pgfcirc@activate@bipole{l}{bjumper}{bjumper}{bare jumper}
\pgfcirc@activate@bipole{l}{ojumper}{ojumper}{open jumper}
\pgfcirc@activate@bipole{l}{cjumper}{cjumper}{closed jumper}
% jumpers
% three pins (two-ways) jumpers
% #1 -> name
% #2 -> height of the first link arc (0 means no link, 1 closed, 2 open)
% #3 -> height of the second link arc (0 means no link, 1 closed, 2 open)
\def\pgf@circ@tjumper@splitstatus#1#2\relax{%split the two values
    \edef\@@a{#1}\edef\@@b{#2}%
}
\pgfcircdeclarebipolescaled{switches}
    {
        % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
        \saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}}
        % shapename
        \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
        % shape type
        \savedmacro{\cshape}{\def\cshape{\ctikzvalof{bipoles/jumper/shape}}}
        % arc characteristics (can vary, must be saved...)
        \savedmacro{\curvature}{\edef\curvature{\ctikzvalof{bipoles/jumper/curvature}}}
        \savedmacro{\openshift}{\edef\openshift{\ctikzvalof{bipoles/jumper/open shift}}}
        \savedmacro{\jumpertype}{\edef\jumpertype{\ctikzvalof{tjumper connections}}}
        %
        \anchor{cout}{\northeast \pgf@y=0cm}
        \anchor{cin}{\southwest\pgf@y=0cm}
        \anchor{ctap}{\pgf@x=0cm\pgf@y=0cm}
        \anchor{out}{\northeast \pgf@y=0cm\advance\pgf@x by \radius}
        \anchor{in}{\southwest\pgf@y=0cm\advance\pgf@x by -\radius}
        \anchor{tap}{\pgf@x=0cm\pgf@y=0cm\advance\pgf@y by -\radius}
        \anchor{top arc left}{\northeast
            \pgf@circ@res@other=-\pgf@x
            \pgf@circ@res@temp=\pgf@x
            %
            % read the status of the jumper
            %
            \expandafter\pgf@circ@tjumper@splitstatus\jumpertype\relax% a bit of magic...
            \edef\@@S{S}%the "S" letter
            \ifx\@@a\@@S %span, it's in the center
                \ifnum \@@b=0\pgfpointorigin\else % no arc, anchor on the center-base
                    \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1}\relax \fi
                    \pgfpointcurveattime{0.5}
                        {\pgfpoint{0.9*\pgf@circ@res@other}{(\@@b)*\radius}}
                        {\pgfpoint{.5*\pgf@circ@res@other}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{.5*\pgf@circ@res@temp}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{0.9*\pgf@circ@res@temp}{(\@@b)*\radius}}
                \fi
            \else
                % adjust the lengths of the gap, if needed
                \ifnum \@@a=2 \edef\@@a{\openshift} \else \edef\@aa{1} \relax \fi
                \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1} \relax \fi
                % left join
                \ifnum \@@a=0 \pgfpoint{0.475*\pgf@circ@res@other}{0pt}\else
                    \pgfpointcurveattime{0.5}
                        {\pgfpoint{0.95*\pgf@circ@res@other}{\@@a*\radius}}
                        {\pgfpoint{.75*\pgf@circ@res@other}{(\@@a+\curvature)*\radius}}
                        {\pgfpoint{.25*\pgf@circ@res@other}{(\@@a+\curvature)*\radius}}
                        {\pgfpoint{0.05*\pgf@circ@res@other}{\@@a*\radius}}
                \fi
            \fi
        }
        \anchor{top arc right}{\northeast
            \pgf@circ@res@other=-\pgf@x
            \pgf@circ@res@temp=\pgf@x
            %
            % read the status of the jumper
            %
            \expandafter\pgf@circ@tjumper@splitstatus\jumpertype\relax% a bit of magic...
            \edef\@@S{S}%the "S" letter
            \ifx\@@a\@@S %span, it's in the center
                \ifnum \@@b=0\pgfpointorigin\else % no arc, anchor on the center-base
                    \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1}\relax \fi
                    \pgfpointcurveattime{0.5}
                        {\pgfpoint{0.9*\pgf@circ@res@other}{(\@@b)*\radius}}
                        {\pgfpoint{.5*\pgf@circ@res@other}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{.5*\pgf@circ@res@temp}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{0.9*\pgf@circ@res@temp}{(\@@b)*\radius}}
                \fi
            \else
                % adjust the lengths of the gap, if needed
                \ifnum \@@a=2 \edef\@@a{\openshift} \else \edef\@aa{1} \relax \fi
                \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1} \relax \fi
                % right join
                \ifnum \@@b=0 \pgfpoint{0.475*\pgf@circ@res@temp}{0pt}\else
                    \pgfpointcurveattime{0.5}
                        {\pgfpoint{0.95*\pgf@circ@res@temp}{\@@b*\radius}}
                        {\pgfpoint{.75\pgf@circ@res@temp}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{.25\pgf@circ@res@temp}{(\@@b+\curvature)*\radius}}
                        {\pgfpoint{0.05*\pgf@circ@res@temp}{\@@b*\radius}}
                \fi
            \fi
        }
    }
    {\ctikzvalof{bipoles/jumper/depth}}
    {tjumper}
    {\ctikzvalof{bipoles/jumper/height}}
    {\ctikzvalof{bipoles/tjumper/width}}{
        %
        % read the status of the jumper
        %
        \expandafter\pgf@circ@tjumper@splitstatus\jumpertype\relax% a bit of magic...
        \edef\@@S{S}%the "S" letter
        \ifx\@@a\@@S %span
            \ifnum \@@b=0 \else
                \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1}\relax \fi
                \pgfpathmoveto{\pgfpoint{0.9*\pgf@circ@res@left}{(\@@b)*\radius}}
                \pgfpathcurveto
                    {\pgfpoint{.5\pgf@circ@res@left}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{.5\pgf@circ@res@right}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{0.9*\pgf@circ@res@right}{(\@@b)*\radius}}
                \pgfusepath{draw}
            \fi
        \else
        % let's do the connection, if needed
            % adjust the lengths of the gap, if needed
            \ifnum \@@a=2 \edef\@@a{\openshift} \else \edef\@aa{1} \relax \fi
            \ifnum \@@b=2 \edef\@@b{\openshift} \else \edef\@bb{1} \relax \fi
            % left arc
            \ifnum \@@a=0 \else
                \pgfpathmoveto{\pgfpoint{0.95*\pgf@circ@res@left}{\@@a*\radius}}
                \pgfpathcurveto
                    {\pgfpoint{.75\pgf@circ@res@left}{(\@@a+\curvature)*\radius}}
                    {\pgfpoint{.25\pgf@circ@res@left}{(\@@a+\curvature)*\radius}}
                    {\pgfpoint{0.05*\pgf@circ@res@left}{\@@a*\radius}}
                \pgfusepath{draw}
            \fi
            % right arc
            \ifnum \@@b=0 \else
                \pgfpathmoveto{\pgfpoint{0.95*\pgf@circ@res@right}{\@@b*\radius}}
                \pgfpathcurveto
                    {\pgfpoint{.75\pgf@circ@res@right}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{.25\pgf@circ@res@right}{(\@@b+\curvature)*\radius}}
                    {\pgfpoint{0.05*\pgf@circ@res@right}{\@@b*\radius}}
                \pgfusepath{draw}
            \fi
        \fi
        % draw the poles (always filled!)
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{draw}}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-tap}{\pgfusepath{draw}}
        \pgftransformshift{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-out}{\pgfusepath{draw}}
    }

\pgfcirc@activate@bipole{l}{tjumper}{tjumper}{three-pins jumper}

% %>>>

% solder jumpers: definitions and code %<<<
\ctikzset{bipoles/solder jumper/width/.initial=0.36}
\ctikzset{bipoles/solder jumper/height/.initial=0.3} % must be less than width, otherwise no gap!
\ctikzset{bipoles/solder jumper/close height/.initial=0.6}% fraction of the vertical gap filled
\ctikzset{bipoles/double solder jumper/width/.initial=0.57}
%
\def\pgfcirc@base@solder@jumper{%
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@up}{\pgf@circ@res@up}}
    \pgfpatharc{90}{270}{\pgf@circ@res@up}
    \pgfpathclose
    \pgfusepath{draw,fill}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@up}{\pgf@circ@res@up}}
    \pgfpatharc{90}{-90}{\pgf@circ@res@up}
    \pgfpathclose
    \pgfusepath{draw,fill}
}
% simple solder jumpers
% #1 -> name
% #2 -> open or close (0 means open, 1 closed)
\long\def\pgfcircdeclaresolderjumper#1#2{
    \pgfcircdeclarebipolescaled{switches}
        {
            \anchor{out}{\northeast \pgf@y=0cm}
            \anchor{in}{\southwest\pgf@y=0cm}
            \anchor{text}{\northeast
                \pgf@x=\dimexpr -.5\wd\pgfnodeparttextbox\relax
                \advance\pgf@y by .6\ht\pgfnodeparttextbox\relax
            }
        }
        {\ctikzvalof{bipoles/solder jumper/height}}
        {#1}
        {\ctikzvalof{bipoles/solder jumper/height}}
        {\ctikzvalof{bipoles/solder jumper/width}}{
            %
            \pgfcirc@base@solder@jumper
            \ifnum #2=0 \else
                \pgfpathrectanglecorners
                {\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@up}
                    {\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@up}}
                {\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@up}
                    {\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@down}}
                \pgfusepath{fill, draw}
            \fi
        }
}
\pgfcircdeclaresolderjumper{osjumper}{0}
\pgfcircdeclaresolderjumper{csjumper}{1}
\pgfcirc@activate@bipole{l}{osjumper}{osjumper}{open solder jumper}
\pgfcirc@activate@bipole{l}{csjumper}{csjumper}{closed solder jumper}
% three pins (two-ways) solder jumpers
% #1 -> name
% #2 -> first side open or closed
% #3 -> second side open or closed
\long\def\pgfcircdeclaredoublesolderjumper#1#2#3{
    \pgfcircdeclarebipolescaled{switches}
        {
            %
            \anchor{out}{\northeast \pgf@y=0cm}
            \anchor{in}{\southwest\pgf@y=0cm}
            \anchor{tap}{\northeast\pgf@x=0cm}
            \anchor{tap up}{\northeast\pgf@x=0cm}
            \anchor{tap down}{\northeast\pgf@x=0cm\pgf@y=-\pgf@y}
            \anchor{text}{\northeast
                \pgf@x=\dimexpr -.5\wd\pgfnodeparttextbox\relax
                \advance\pgf@y by .6\ht\pgfnodeparttextbox\relax
            }
        }
        {\ctikzvalof{bipoles/solder jumper/height}}
        {#1}
        {\ctikzvalof{bipoles/solder jumper/height}}
        {\ctikzvalof{bipoles/double solder jumper/width}}
        {
            \pgfcirc@base@solder@jumper
            \pgfpathrectanglecorners
                {\pgfpoint{-.5\pgf@circ@res@up}{\pgf@circ@res@up}}
                {\pgfpoint{.5\pgf@circ@res@up}{\pgf@circ@res@down}}
                \pgfusepath{fill, draw}
            \ifnum #2=0 \else
                \pgfpathrectanglecorners
                    {\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@up}{\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@up}}
                    {\pgfpoint{-.5\pgf@circ@res@up}{\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@down}}
                    \pgfusepath{fill, draw}
            \fi
            \ifnum #3=0 \else
                \pgfpathrectanglecorners
                    {\pgfpoint{\pgf@circ@res@right-\pgf@circ@res@up}{\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@up}}
                    {\pgfpoint{.5\pgf@circ@res@up}{\ctikzvalof{bipoles/solder jumper/close height}\pgf@circ@res@down}}
                    \pgfusepath{fill, draw}
            \fi
        }
}
%
\pgfcircdeclaredoublesolderjumper{odsjumper}{0}{0}
\pgfcircdeclaredoublesolderjumper{ldsjumper}{1}{0}
\pgfcircdeclaredoublesolderjumper{rdsjumper}{0}{1}
\pgfcircdeclaredoublesolderjumper{cdsjumper}{1}{1}
\pgfcirc@activate@bipole{l}{odsjumper}{odsjumper}{open double solder jumper}
\pgfcirc@activate@bipole{l}{ldsjumper}{ldsjumper}{left double solder jumper}
\pgfcirc@activate@bipole{l}{rdsjumper}{rdsjumper}{right double solder jumper}
\pgfcirc@activate@bipole{l}{cdsjumper}{cdsjumper}{closed double solder jumper}

% %>>>

%%%%%%%%%%%%%%%%%
%% Instruments
%%%%%%%%%%%%%%%%%

%% Definitions for Instruments %<<<1
\ctikzset{bipoles/ammeter/height/.initial=.60}
\ctikzset{bipoles/ammeter/width/.initial=.60}
\ctikzset{bipoles/ohmmeter/height/.initial=.60}
\ctikzset{bipoles/ohmmeter/width/.initial=.60}
\ctikzset{bipoles/voltmeter/height/.initial=.60}
\ctikzset{bipoles/voltmeter/width/.initial=.60}
\ctikzset{bipoles/smeter/height/.initial=.60}
\ctikzset{bipoles/smeter/width/.initial=.60}
\ctikzset{bipoles/smeter/voltage/additional shift/.initial=1}
\ctikzset{bipoles/qmeter/depth/.initial=.40}
\ctikzset{bipoles/qmeter/height/.initial=.80}
\ctikzset{bipoles/qmeter/width/.initial=.60}
% this must be specified for each one
\ctikzset{bipoles/qvprobe/voltage/additional shift/.initial=.5}
\ctikzset{bipoles/qiprobe/voltage/additional shift/.initial=.5}
\ctikzset{bipoles/qpprobe/voltage/additional shift/.initial=.5}
\ctikzset{bipoles/iloop/width/.initial=.40}
\ctikzset{bipoles/iloop/height/.initial=.60}

\ctikzset{bipoles/oscope/height/.initial=.60}
\ctikzset{bipoles/oscope/width/.initial=.60}
\ctikzset{bipoles/oscope/voltage/additional shift/.initial=1}


% option to not rotate the new (Romano's) instruments
\newif\ifpgf@circuit@straightinstruments\pgf@circuit@straightinstrumentstrue
\pgfkeys{/tikz/straight instruments/.add code={}{\pgf@circuit@straightinstrumentstrue}}
\ctikzset{straight instruments/.add code={}{\pgf@circuit@straightinstrumentstrue}}
\pgfkeys{/tikz/rotated instruments/.add code={}{\pgf@circuit@straightinstrumentsfalse}}
\ctikzset{rotated instruments/.add code={}{\pgf@circuit@straightinstrumentsfalse}}
%%>>>

%% Node shapes for instruments%<<<

% % METERINGSHAPE
\long\def\drawmeteringcircle{
    \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
    %draw connections to circle
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{.9\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathmoveto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
    %draw circle
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathcircle{\pgfpointorigin}{.9\pgf@circ@res@up}
        \pgf@circ@draworfill
    \endpgfscope
    %draw arrow
    \pgfscope
        \pgfsetarrowsend{latex}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

%AMPEREMETER
\pgfcircdeclarebipolescaled{instruments}
{}
{\ctikzvalof{bipoles/ammeter/height}}
{ammeter}
{\ctikzvalof{bipoles/ammeter/height}}
{\ctikzvalof{bipoles/ammeter/width}}
{
    \drawmeteringcircle
    \pgfnode{circle}{center}{\pgf@circ@font@bold{A}}{}{}
}
%OHMMETER
\pgfcircdeclarebipolescaled{instruments}
{}
{\ctikzvalof{bipoles/ohmmeter/height}}
{ohmmeter}
{\ctikzvalof{bipoles/ohmmeter/height}}
{\ctikzvalof{bipoles/ohmmeter/width}}
{
    \drawmeteringcircle
    \pgfnode{circle}{center}{\boldmath$\Omega$}{}{}
}
%VOLTMETER
\pgfcircdeclarebipolescaled{instruments}
{}
{\ctikzvalof{bipoles/voltmeter/height}}
{voltmeter}
{\ctikzvalof{bipoles/voltmeter/height}}
{\ctikzvalof{bipoles/voltmeter/width}}
{
    \drawmeteringcircle
    \pgfnode{circle}{center}{\pgf@circ@font@bold{V}}{}{}

}

% oscilloscope, suggested by @nobrl https://github.com/circuitikz/circuitikz/issues/176
%
% oscilloscope waveforms

\ctikzset{%
    bipoles/oscope/waveform/sin/.code={%
        \pgfpathmoveto{\pgfpoint{-0.6cm}{0cm}}
        \pgfpathsine{\pgfpoint{0.3cm}{0.4cm}}
        \pgfpathcosine{\pgfpoint{0.3cm}{-0.4cm}}
        \pgfpathsine{\pgfpoint{0.3cm}{-0.4cm}}
        \pgfpathcosine{\pgfpoint{0.3cm}{0.4cm}}
        \pgfusepath{draw}
    },
    bipoles/oscope/waveform/ramps/.code={%
        \pgfpathmoveto{\pgfpoint{-0.75cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{-0.05cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{-0.05cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{0.65cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0.65cm}{-0.25cm}}
        \pgfusepath{draw}
    },
    bipoles/oscope/waveform/square/.code={%
        \pgfpathmoveto{\pgfpoint{-0.75cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{-0.6cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{-0.6cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{0.6cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{0.6cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0.75cm}{0.25cm}}
        \pgfusepath{draw}
    },
    bipoles/oscope/waveform/triangle/.code={%
        \pgfpathmoveto{\pgfpoint{-0.75cm}{0cm}}
        \pgfpathlineto{\pgfpoint{-0.6cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{-0.3cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{0.3cm}{0.25cm}}
        \pgfpathlineto{\pgfpoint{0.6cm}{-0.25cm}}
        \pgfpathlineto{\pgfpoint{0.75cm}{0cm}}
        \pgfusepath{draw}
    },
    bipoles/oscope/waveform/zero/.code={
        \pgfpathmoveto{\pgfpoint{-0.75cm}{0cm}}
        \pgfpathlineto{\pgfpoint{0.75cm}{0cm}}
        \pgfusepath{draw}
        },%
    bipoles/oscope/waveform/lissajous/.code={%
        \pgfpathellipse{\pgfpoint{0cm}{0cm}}
            {\pgfpoint{0.5cm}{0.35cm}}{\pgfpoint{-0.3cm}{0.2cm}}
        \pgfusepath{draw}
    },
    bipoles/oscope/waveform/none/.code={},%
}
% default waveform (backward compatible)
\ctikzset{bipoles/oscope/waveform/.initial=ramps}

\pgfcircdeclarebipolescaled{instruments}
{
    \anchor{in 1}{\southwest\pgf@y=0.75\pgf@y\pgf@x=0.4\pgf@x}
    \anchor{in 2}{\southwest\pgf@y=0.75\pgf@y\pgf@x=-0.4\pgf@x}
    % put the node text above and centered
    \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfpoint{-.5\wd\pgfnodeparttextbox}{
            \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax
        }
    }
}
{\ctikzvalof{bipoles/oscope/height}}
{oscope}
{\ctikzvalof{bipoles/oscope/height}}
{\ctikzvalof{bipoles/oscope/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgfextractx{\pgf@circ@res@left}{\southwest}
    \pgfextracty{\pgf@circ@res@down}{\southwest}
    \pgfmathsetlength{\pgf@circ@res@step}{0.25*\pgf@circ@res@up}
    \pgfscope
        \pgfsetcornersarced{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@step}}
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgf@circ@draworfill
    \endpgfscope
    % get the rotation
    \ifpgf@circuit@straightinstruments
        \pgfgettransformentries\a\b\temp\temp\temp\temp
        \pgfmathsetmacro{\rot}{-atan2(\b,\a)}
    \else
        \edef\rot{0}
    \fi
    % and unrotate the scope
    \pgfscope
        \pgftransformrotate{\rot}
        % grid
        \pgfscope
            \pgfsetlinewidth{0.5\pgfstartlinewidth}
            \pgfpathmoveto{\pgfpoint{0.75\pgf@circ@res@left}{0.25\pgf@circ@res@down}}
            % the "almost one" make the grid complete most of the time --- beware of antialiasing
            \pgfpathgrid[stepx=0.995\pgf@circ@res@step, stepy=0.995\pgf@circ@res@step]%
            {\pgfpoint{0.75\pgf@circ@res@left}{0.5\pgf@circ@res@down}}
            {\pgfpoint{0.75\pgf@circ@res@right}{0.5\pgf@circ@res@up}}
            \pgfsetstrokeopacity{0.5}
            \pgfusepath{draw}
        \endpgfscope
        % function displayed
        \pgfscope
            \pgfmathsetmacro{\@@scalex}{\pgf@circ@res@right/1cm}
            \pgfmathsetmacro{\@@scaley}{\pgf@circ@res@up/1cm}
            \pgftransformxscale{\@@scalex}
            \pgftransformyscale{\@@scaley}
            \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
            \pgfkeys{\circuitikzbasekey/bipoles/oscope/waveform/\ctikzvalof{bipoles/oscope/waveform}}
        \endpgfscope
    \endpgfscope
}
% generic round meter with always horizontal text, no arrow
\pgfcircdeclarebipolescaled{instruments}
{}
{\ctikzvalof{bipoles/esource/height}}
{rmeter}
{\ctikzvalof{bipoles/esource/height}}
{\ctikzvalof{bipoles/esource/width}}
{
    \pgfpointorigin
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@draworfill
    \endpgfscope
    % draw the text label
    % get the rotation
    \ifpgf@circuit@straightinstruments
        \pgfgettransformentries\a\b\temp\temp\temp\temp
        \pgfmathsetmacro{\rot}{-atan2(\b,\a)}
    \else
        \edef\rot{0}
    \fi
    % and unrotate the scope
    \pgfscope
    \pgf@circ@text@strokecolor
        \pgftransformrotate{\rot}
        \pgftext[center,x=0,y=0]{\ctikzvalof{bipoles/twoport/text}}
    \endpgfscope
}

% generic round meter with always horizontal text, with arrow
\pgfcircdeclarebipolescaled{instruments}
{}
{\ctikzvalof{bipoles/esource/height}}
{rmeterwa}
{\ctikzvalof{bipoles/esource/height}}
{\ctikzvalof{bipoles/esource/width}}
{
    \pgfpointorigin
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgf@circ@draworfill
    \endpgfscope
    % draw the text label
    % get the rotation
    \ifpgf@circuit@straightinstruments
        \pgfgettransformentries\a\b\temp\temp\temp\temp
        \pgfmathsetmacro{\rot}{-atan2(\b,\a)}
    \else
        \edef\rot{0}
    \fi
    % and unrotate the scope
    \pgfscope
        \pgftransformrotate{\rot}
        \pgf@circ@setcolor
        \pgfsetlinewidth{\pgfstartlinewidth}
        % arrow: create  a center hole to have better visual
        \pgfscope
            % clipping path: first a rectangle bigger then the shape
            % to avoid problems with the line thickness
            \pgfpathrectanglecorners{\pgfpoint{2\pgf@circ@res@left}{2\pgf@circ@res@down}}
            {\pgfpoint{2\pgf@circ@res@right}{2\pgf@circ@res@up}}
            % next open a circle into it
            \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{.6\pgf@circ@res@up}}{\pgfpoint{.6\pgf@circ@res@left}{0}}
            % do the difference and clip before drawing
            \pgfseteorule
            \pgfusepath{clip}
            \pgfsetarrowsend{latexslim}
            % the arrow is better if it has a bit of breath and it's not 45º
            \pgfpathmoveto{\pgfpoint{.8\pgf@circ@res@left}{1.2\pgf@circ@res@down}}
            \pgfpathlineto{\pgfpoint{.8\pgf@circ@res@right}{1.2\pgf@circ@res@up}}
            \pgfusepath{draw}
        \endpgfscope
        \pgf@circ@text@strokecolor
        \pgftext[center]{\ctikzvalof{bipoles/twoport/text}}
    \endpgfscope
}

% generic square meter with always horizontal text
\pgfcircdeclarebipolescaled{instruments}
{
    \anchor{in 1}{\southwest\pgf@y=0.75\pgf@y\pgf@x=0.4\pgf@x}
    \anchor{in 2}{\southwest\pgf@y=0.75\pgf@y\pgf@x=-0.4\pgf@x}
    % put the node text above and centered
    \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfpoint{-.5\wd\pgfnodeparttextbox}{
            \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax
        }
    }
}
{\ctikzvalof{bipoles/smeter/height}}
{smeter}
{\ctikzvalof{bipoles/smeter/height}}
{\ctikzvalof{bipoles/smeter/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgfextractx{\pgf@circ@res@left}{\southwest}
    \pgfextracty{\pgf@circ@res@down}{\southwest}
    \pgfmathsetlength{\pgf@circ@res@step}{0.25*\pgf@circ@res@up}
    \pgfscope
        \pgfsetcornersarced{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@step}}
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgf@circ@draworfill
    \endpgfscope
    % get the rotation
    \ifpgf@circuit@straightinstruments
        \pgfgettransformentries\a\b\temp\temp\temp\temp
        \pgfmathsetmacro{\rot}{-atan2(\b,\a)}
    \else
        \edef\rot{0}
    \fi
    % and unrotate the scope
    \pgfscope
        \pgftransformrotate{\rot}
        % the metering window
        \pgfscope
            \def\@starta{105}\def\@stopa{75}
            \pgfsetlinewidth{\pgfstartlinewidth}
            \pgftransformshift{\pgfpoint{0pt}{-1.8\pgf@circ@res@up}}
            \pgfpathmoveto{\pgfpointpolar{\@starta}{2\pgf@circ@res@up}}
            \pgfpatharc{\@starta}{\@stopa}{2\pgf@circ@res@up}
            \pgfpathlineto{\pgfpointpolar{\@stopa}{2.5\pgf@circ@res@up}}
            \pgfpatharc{\@stopa}{\@starta}{2.5\pgf@circ@res@up}
            \pgfpathclose
            \pgfpathmoveto{\pgfpointpolar{80}{2\pgf@circ@res@up}}
            \pgfpathlineto{\pgfpointpolar{80}{2.4\pgf@circ@res@up}}
            \pgfusepath{draw}
        \endpgfscope
        \pgf@circ@text@strokecolor
        \pgftext[center, y=0.5\pgf@circ@res@down]{\ctikzvalof{bipoles/twoport/text}}
    \endpgfscope
}

% probes qucs style:
% #1 : name
% #2 : extra code
\long\def\pgfcirc@qucsprobe#1#2{
    \pgfcircdeclarebipolescaled{instruments}
    {
        \anchor{v+}{\southwest\pgf@x=0.6\pgf@x}
        \anchor{v-}{\southwest\pgf@x=-0.6\pgf@x}
        % put the node text above and centered
        \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northeast}
            \pgfpoint{-.5\wd\pgfnodeparttextbox}{
                \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax
            }
        }
    }
    {\ctikzvalof{bipoles/qmeter/depth}}
    {#1}
    {\ctikzvalof{bipoles/qmeter/height}}
    {\ctikzvalof{bipoles/qmeter/width}}
    {
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfextractx{\pgf@circ@res@right}{\northeast}
        \pgfextractx{\pgf@circ@res@left}{\southwest}
        \pgfextracty{\pgf@circ@res@down}{\southwest}
        \pgfmathsetlength{\pgf@circ@res@step}{0.25*\pgf@circ@res@up}
        \pgfscope
            \pgfscope
                \pgfsetcornersarced{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@step}}
                \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
                \pgf@circ@draworfill
            \endpgfscope
            \def\@starta{103}\def\@stopa{77}
            \pgfsetlinewidth{\pgfstartlinewidth}
            \pgfscope
                \pgftransformshift{\pgfpoint{0pt}{-1.7\pgf@circ@res@up}}
                \pgfpathmoveto{\pgfpointpolar{\@starta}{2.1\pgf@circ@res@up}}
                \pgfpatharc{\@starta}{\@stopa}{2.1\pgf@circ@res@up}
                \pgfpathlineto{\pgfpointpolar{\@stopa}{2.5\pgf@circ@res@up}}
                \pgfpatharc{\@stopa}{\@starta}{2.5\pgf@circ@res@up}
                \pgfpathclose
                \pgfpathmoveto{\pgfpointpolar{83}{2.1\pgf@circ@res@up}}
                \pgfpathlineto{\pgfpointpolar{83}{2.4\pgf@circ@res@up}}
                \pgfusepath{draw}
                \pgf@circ@draworfill
            \endpgfscope
            #2%
        \endpgfscope
    }
}

\pgfcirc@qucsprobe{qiprobe}{
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
    \pgfnode{currarrow}{center}{}{}{}
}

\pgfcirc@qucsprobe{qvprobe}{
    \pgfmathsetlength{\pgf@circ@res@other}{\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left}{0pt}}
    \pgfpathcircle{\pgfpoint{.6\pgf@circ@res@left+\pgf@circ@res@other}{0pt}}{\pgf@circ@res@other}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathcircle{\pgfpoint{.6\pgf@circ@res@right-\pgf@circ@res@other}{0pt}}{\pgf@circ@res@other}
    \pgfusepath{draw}
    \pgfscope
        % "+" and "-", drawn so that they scale correctly
        \pgfsetlinewidth{2\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left+\pgf@circ@res@other}{-1.5\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left+\pgf@circ@res@other}{-3.5\pgf@circ@res@other}}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left+0\pgf@circ@res@other}{-2.5\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left+2\pgf@circ@res@other}{-2.5\pgf@circ@res@other}}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@right+0\pgf@circ@res@other}{-2.5\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right-2\pgf@circ@res@other}{-2.5\pgf@circ@res@other}}
        \pgfusepath{draw}
    \endpgfscope
}

\pgfcirc@qucsprobe{qpprobe}{
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
    \pgfnode{currarrow}{center}{}{}{}
    \pgfmathsetlength{\pgf@circ@res@other}{\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}
    \pgfpathcircle{\pgfpoint{.6\pgf@circ@res@left}{-3\pgf@circ@res@other}}{\pgf@circ@res@other}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left}{-4\pgf@circ@res@other}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathcircle{\pgfpoint{.6\pgf@circ@res@right}{-3\pgf@circ@res@other}}{\pgf@circ@res@other}
    \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@right}{-4\pgf@circ@res@other}}
    \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgfscope
        % "+" and "-", drawn so that they scale correctly
        \pgfsetlinewidth{2\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left+3\pgf@circ@res@other}{-2\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left+3\pgf@circ@res@other}{-4\pgf@circ@res@other}}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@left+2\pgf@circ@res@other}{-3\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@left+4\pgf@circ@res@other}{-3\pgf@circ@res@other}}
        \pgfpathmoveto{\pgfpoint{.6\pgf@circ@res@right-4\pgf@circ@res@other}{-3\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right-2\pgf@circ@res@other}{-3\pgf@circ@res@other}}
        \pgfusepath{draw}
    \endpgfscope
}

% current loop for oscope and similar: stylized
\pgfcircdeclarebipolescaled{instruments}
{
    \anchor{i}{\northeast\pgf@x=0pt\relax}
    \anchor{text}{
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfextractx{\pgf@circ@res@left}{\northeast}
        \pgfpoint{-.5\wd\pgfnodeparttextbox+\pgf@circ@res@left}{
            \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax
        }
    }
}
{\ctikzvalof{bipoles/iloop/height}}
{iloop}
{\ctikzvalof{bipoles/iloop/height}}
{\ctikzvalof{bipoles/iloop/width}}
{
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgf@circ@res@down=-\pgf@circ@res@up
    \pgf@circ@res@left=-\pgf@circ@res@right
    \pgfscope
        \pgfstartlinewidth=\pgflinewidth
        \pgf@circ@setcolor
        % external ellipse
        \pgfscope
            \pgf@circ@setlinewidth{bipoles}{\pgflinewidth}
            % clipping path: first a rectangle bigger then the shape
            % to avoid problems with the line thickness
            \pgfpathrectanglecorners{\pgfpoint{2\pgf@circ@res@left}{2\pgf@circ@res@down}}
            {\pgfpoint{2\pgf@circ@res@right}{2\pgf@circ@res@up}}
            % next the opening to the left
            \pgfpathrectanglecorners{\pgfpoint{2\pgf@circ@res@left}{.1\pgf@circ@res@down}}
            {\pgfpoint{0pt}{.1\pgf@circ@res@up}}
            % do the difference and clip before drawing
            \pgfseteorule
            \pgfusepath{clip}
            \pgfpathellipse{\pgfpointorigin}{
                \pgfpoint{0pt}{0.8\pgf@circ@res@up}}{
            \pgfpoint{0.4\pgf@circ@res@right}{0pt}}
            \pgfusepath{draw}
        \endpgfscope
        % internal wire
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{0.3\pgf@circ@res@right}{0pt}}
        \pgfpathmoveto{\pgfpoint{0.5\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        % and the contact line up
        \pgfpathmoveto{\pgfpoint{0pt}{0.8\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}

% current loop for oscope and similar: real (double connection)
\pgfcircdeclarebipolescaled{instruments}
{
    \anchor{i+}{
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfextractx{\pgf@circ@res@right}{\northeast}
        \pgf@circ@res@step=0.4\pgf@circ@res@right
        \pgf@circ@res@other=0.8\pgf@circ@res@up
        \pgfpointpolar{105}{\pgf@circ@res@step and \pgf@circ@res@other}
        \pgf@y=\pgf@circ@res@up
    }
    \anchor{i-}{
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfextractx{\pgf@circ@res@right}{\northeast}
        \pgf@circ@res@step=0.4\pgf@circ@res@right
        \pgf@circ@res@other=0.8\pgf@circ@res@up
        \pgfpointpolar{75}{\pgf@circ@res@step and \pgf@circ@res@other}
        \pgf@y=\pgf@circ@res@up
    }
    \anchor{text}{
        \pgfextracty{\pgf@circ@res@up}{\northeast}
        \pgfextractx{\pgf@circ@res@left}{\northeast}
        \pgfpoint{-.5\wd\pgfnodeparttextbox+\pgf@circ@res@left}{
            \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax
        }
    }
}
{\ctikzvalof{bipoles/iloop/height}}
{iloop2}
{\ctikzvalof{bipoles/iloop/height}}
{\ctikzvalof{bipoles/iloop/width}}
{
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgf@circ@res@down=-\pgf@circ@res@up
    \pgf@circ@res@left=-\pgf@circ@res@right
    % must be the same than internal i+ and i- anchors definition
    \pgf@circ@res@step=0.4\pgf@circ@res@right
    \pgf@circ@res@other=0.8\pgf@circ@res@up
    \def\@plus{\pgfpointpolar{105}{\pgf@circ@res@step and \pgf@circ@res@other}}
    \def\@minus{\pgfpointpolar{75}{\pgf@circ@res@step and \pgf@circ@res@other}}
    \pgfscope
        \pgfstartlinewidth=\pgflinewidth
        \pgf@circ@setcolor
        % external ellipse
        \pgfscope
            \pgf@circ@setlinewidth{bipoles}{\pgflinewidth}
            % clipping path: first a rectangle bigger then the shape
            % to avoid problems with the line thickness
            \pgfpathrectanglecorners{\pgfpoint{2\pgf@circ@res@left}{2\pgf@circ@res@down}}
            {\pgfpoint{2\pgf@circ@res@right}{2\pgf@circ@res@up}}
            % next the opening to the left
            \pgfpathrectanglecorners{\pgfpoint{2\pgf@circ@res@left}{.1\pgf@circ@res@down}}
            {\pgfpoint{0pt}{.1\pgf@circ@res@up}}
            % do the difference and clip before drawing
            \pgfseteorule
            \pgfusepath{clip}
            \pgfpathmoveto{\@plus}
            \pgfpatharc{105}{435}{\pgf@circ@res@step and \pgf@circ@res@other}
            \pgfusepath{draw}
        \endpgfscope
        % internal wire
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{0.3\pgf@circ@res@right}{0pt}}
        \pgfpathmoveto{\pgfpoint{0.5\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        % and the contact line up
        % I use ...left and ---right as temporal lengths here to avoid defining more
        \pgfextractx{\pgf@circ@res@left}{\@plus}
        \pgfextractx{\pgf@circ@res@right}{\@minus}
        \pgfpathmoveto{\@plus}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathmoveto{\@minus}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfusepath{draw}
    \endpgfscope
}
% %>>>

% Path definitions for Instruments%<<<

\pgfcirc@activate@bipole@simple{l}{ammeter}
\pgfcirc@activate@bipole@simple{l}{ohmmeter}
\pgfcirc@activate@bipole@simple{l}{voltmeter}
\pgfcirc@activate@bipole@simple{l}{oscope}
\pgfcirc@activate@bipole@simple{l}{rmeter}
\pgfcirc@activate@bipole@simple{l}{rmeterwa}
\pgfcirc@activate@bipole@simple{l}{smeter}
\pgfcirc@activate@bipole@simple{l}{iloop}
% \pgfcirc@activate@bipole@simple{l}{iloop2} that was wrong
\pgfcirc@activate@bipole{l}{ilooptwo}{iloop2}{iloop2}
\pgfcirc@activate@bipole@simple{l}{qvprobe}
\pgfcirc@activate@bipole@simple{l}{qiprobe}
\pgfcirc@activate@bipole@simple{l}{qpprobe}
% %>>>

%%%%%%%%%%%%%%%%%%%%%%%
%% MECHANICAL SYMBOLS
%%%%%%%%%%%%%%%%%%%%%%%

%% Settings for Mechanical section%<<<1
\ctikzset{/tikz/circuitikz/tripoles/elmech/height/.initial=.8}
\ctikzset{/tikz/circuitikz/tripoles/elmech/width/.initial=.6}
\ctikzset{bipoles/spring/height/.initial=.5}
\ctikzset{bipoles/spring/width/.initial=.5}
\ctikzset{bipoles/inerter/height/.initial=.7}
\ctikzset{bipoles/inerter/width/.initial=.175}
\ctikzset{bipoles/mass/height/.initial=.55}
\ctikzset{bipoles/mass/box height/.initial=.4}
\ctikzset{bipoles/mass/width/.initial=.5}

\ctikzset{bipoles/damper/height/.initial=.35}
\ctikzset{bipoles/damper/length/.initial=.3}
\ctikzset{bipoles/damper/width/.initial=.4}
%%>>>

%% Node shapes Mechanical analog system%<<<
%% mechanical capacitance - stiffness/spring

\pgfcircdeclarebipolescaled{mechanicals}
{}
{\ctikzvalof{bipoles/spring/height}}
{spring}
{\ctikzvalof{bipoles/spring/height}}
{\ctikzvalof{bipoles/spring/width}}{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments

    \pgfmathsetlength{\pgf@circ@res@step}
    {(\ctikzvalof{bipoles/spring/width}*\pgf@circ@scaled@Rlen+\pgfhorizontaltransformationadjustment*.5*\pgflinewidth)/16}

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*0.5*\pgflinewidth}{\pgf@circ@res@zero}}
    \pgfsetcornersarced{\pgfpoint{.5\pgf@circ@res@up}{.5\pgf@circ@res@up}}
    \pgf@circ@res@other = \pgf@circ@res@left
    \advance\pgf@circ@res@other by \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 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}}
    \pgfsetbuttcap
    \pgfsetbeveljoin
    \pgfusepath{stroke}
}

%% mechanical capacitance - inerter
\pgfcircdeclarebipolescaled{mechanicals}
{}
{\ctikzvalof{bipoles/inerter/height}}
{inerter}
{\ctikzvalof{bipoles/inerter/height}}
{\ctikzvalof{bipoles/inerter/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
}


%% mechanical inductance - mass
\pgfcircdeclarebipolescaled{mechanicals}
{}
{\ctikzvalof{bipoles/mass/box height}}
{mass}
{\ctikzvalof{bipoles/mass/height}}
{\ctikzvalof{bipoles/mass/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgftransformationadjustments
    \pgfpathrectangle{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        {\pgfpoint{-2\pgf@circ@res@down}{-2\pgf@circ@res@down}}
    \pgf@circ@draworfill

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfsetrectcap
    \pgfsetmiterjoin
    \pgfusepath{stroke}
}

%% mechanical resistor - damper
\pgfcircdeclarebipolescaled{mechanicals}
{}
{\ctikzvalof{bipoles/damper/height}}
{damper}
{\ctikzvalof{bipoles/damper/height}}
{\ctikzvalof{bipoles/damper/width}}
{
    \pgfpathrectanglecorners{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgf@circ@maybefill

    % line into the damper
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
        {\pgf@circ@res@zero}}
    \pgfusepath{stroke}

    % damper box
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}

    \pgfsetrectcap
    \pgfsetmiterjoin
    \pgfusepath{stroke}

    % damper vertical element
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
        {.8\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
        {.8\pgf@circ@res@up}}
    \pgfsetbuttcap
    \pgfusepath{stroke}

}
%% mechanical viscoelastic element, suggested by @alex
%% in https://tex.stackexchange.com/questions/484268/combined-spring-damper-in-circuitikz
\pgfcircdeclarebipolescaled{mechanicals}
{}                                   % extra anchors
{\ctikzvalof{bipoles/damper/height}} % depth (under the path line)
{viscoe}                             % name
{\ctikzvalof{bipoles/damper/height}} % height (above the path line)
{\ctikzvalof{bipoles/damper/width}}  % width
{ % draw the bipole
    \pgfpathrectanglecorners{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{\pgf@circ@res@down}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgf@circ@maybefill

    % spring into the damper
    \pgfscope
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfsetcornersarced{\pgfpoint{.25\pgf@circ@res@up}{.25\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.75\pgf@circ@res@left}{.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.5\pgf@circ@res@left}{-.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.25\pgf@circ@res@left}{.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{-.75\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}{.75\pgf@circ@res@up}}
        \pgfusepath{stroke}
    \endpgfscope
    % damper box
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}

    \pgfsetrectcap
    \pgfsetmiterjoin
    \pgfusepath{stroke}

    % damper vertical element
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
        {.8\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/damper/length}\pgf@circ@res@right}
        {.8\pgf@circ@res@up}}
    \pgfsetbuttcap
    \pgfusepath{stroke}

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% electromechanical device (motor/generator)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pgfdeclareshape{elmech}
{
    \savedmacro{\ctikzclass}{\edef\ctikzclass{electromechanicals}}
    \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
    \savedanchor\northwest{
        \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
        \pgf@y=\ctikzvalof{tripoles/elmech/height}\pgf@circ@scaled@Rlen
        \pgf@y=.5\pgf@y
        \pgf@x=-\ctikzvalof{tripoles/elmech/width}\pgf@circ@scaled@Rlen
        \pgf@x=.5\pgf@x
    }
    \anchor{center}{
        \pgfpointorigin
    }
    \anchor{text}{
        \pgfpointorigin
        \advance \pgf@x by -.5\wd\pgfnodeparttextbox
        \advance \pgf@y by -.5\ht\pgfnodeparttextbox
    }
    \anchor{left}{%
        \northwest
        \pgf@y=0pt
    }
    \anchor{right}{%
        \northwest
        \pgf@y=0pt
        \pgf@x=-\pgf@x
    }
    \anchor{top}{
        \northwest
        \pgf@x=0pt
    }
    \anchor{pathstart}{
        \northwest
        \pgf@x=0pt
    }
    \anchor{pathend}{
        \northwest
        \pgf@x=0pt
        \pgf@y=-\pgf@y
    }
    \anchor{bottom}{
        \northwest
        \pgf@x=0pt
        \pgf@y=-\pgf@y
    }
    \anchor{center}{
        \pgf@y=0pt
        \pgf@x=0pt
    }
    \anchor{east}{
        \northwest
        \pgf@y=0pt
        \pgf@x=-\pgf@x
    }
    \anchor{west}{
        \northwest
        \pgf@y=0pt
    }
    \anchor{south}{
        \northwest
        \pgf@x=0pt
        \pgf@y=-\pgf@y
    }
    \anchor{north}{
        \northwest
        \pgf@x=0pt
    }
    \anchor{south west}{ \northwest \pgf@y=-\pgf@y }
    \anchor{north east}{ \northwest \pgf@x=-\pgf@x }
    \anchor{north west}{ \northwest }
    \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y }
    \anchorborder{%
        \@tempdima=\pgf@x\@tempdimb=\pgf@y
        \northwest\pgf@circ@res@other=-\pgf@x
        \pgfpointborderellipse{\pgfqpoint{\@tempdima}{\@tempdimb}}{\pgfqpoint{\pgf@circ@res@other}{\pgf@circ@res@other}}
    }
    \anchor{block north west}{\northwest\pgf@x=0.5\pgf@x}
    \anchor{block south west}{\northwest\pgf@x=0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{block north east}{\northwest\pgf@x=-0.5\pgf@x}
    \anchor{block south east}{\northwest\pgf@x=-0.5\pgf@x\pgf@y=-\pgf@y}
    \anchor{block up right}{
        \northwest
        % remember that pgf@x is negative
        % center of the block is at 0.5*H+W*cos(30)/2
        \pgf@y=\dimexpr0.5\pgf@y - 0.433\pgf@x\relax
        \pgf@x=-0.5\pgf@x
    }
    \anchor{block up left}{
        \northwest
        % remember that pgf@x is negative
        % center of the block is at 0.5*H+W*cos(30)/2
        \pgf@y=\dimexpr0.5\pgf@y - 0.433\pgf@x\relax
        \pgf@x=0.5\pgf@x
    }
    \anchor{block down right}{
        \northwest
        % remember that pgf@x is negative
        % center of the block is at 0.5*H+W*cos(30)/2
        \pgf@y=\dimexpr0.5\pgf@y - 0.433\pgf@x\relax
        \pgf@y=-\pgf@y
        \pgf@x=-0.5\pgf@x
    }
    \anchor{block down left}{
        \northwest
        % remember that pgf@x is negative
        % center of the block is at 0.5*H+W*cos(30)/2
        \pgf@y=\dimexpr0.5\pgf@y - 0.433\pgf@x\relax
        \pgf@y=-\pgf@y
        \pgf@x=0.5\pgf@x
    }
    \pgf@circ@draw@component{
        \pgf@circ@setcolor
        \pgf@circ@scaled@Rlen=\scaledRlen
        \pgf@circ@res@step=\ctikzvalof{tripoles/elmech/width}\pgf@circ@scaled@Rlen
        \pgf@circ@res@up=\ctikzvalof{tripoles/elmech/height}\pgf@circ@scaled@Rlen
        \pgfscope
            \pgfstartlinewidth=\pgflinewidth
            \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
            \pgfscope % clip the bar: whole size minus the circle
                \pgfpathrectanglecorners{\pgfpoint{-.5\pgf@circ@res@step}{-.5\pgf@circ@res@up}}{\pgfpoint{.5\pgf@circ@res@step}{.5\pgf@circ@res@up}}
                \pgfpathcircle{\pgfpoint{0}{0}} {0.5\pgf@circ@res@step}
                \pgfseteorule
                \pgfusepath{clip}
                \pgfpathrectangle{\pgfpoint{-.25\pgf@circ@res@step}{-.5\pgf@circ@res@up}}{\pgfpoint{.5\pgf@circ@res@step}{\pgf@circ@res@up}}
                \pgf@circ@fill@strokecolor
                \pgfusepath{fill, draw}
            \endpgfscope
            \pgfpathcircle{\pgfpoint{0}{0}} {0.5\pgf@circ@res@step}
            \ifx\tikz@fillcolor\pgfutil@empty
                % set the default fill color to white
                \pgfsetfillcolor{white}
                % ...but override it if the class is defined!
                \pgf@circ@setifdefinedfill{draw, fill}{draw, fill}
            \else
                \pgfsetfillcolor{\tikz@fillcolor}
                \pgfusepath{draw, fill}
            \fi
        \endpgfscope
    }
}

% %>>>

%% Path definitions for Mechanical%<<<

\pgf@circ@definetranspath{elmech}
\pgfcirc@activate@bipole@simple{l}{spring}
\pgfcirc@activate@bipole@simple{l}{inerter}
\pgfcirc@activate@bipole@simple{l}{mass}
\pgfcirc@activate@bipole@simple{l}{damper}
\pgfcirc@activate@bipole@simple{l}{viscoe}
% %>>>

%%%%%%%%%%%%%%%%%%%%%%%%%
%% Miscellaneous bipoles
%%%%%%%%%%%%%%%%%%%%%%%%%

% settings for microphone, loudspeaker, fuses and misc%<<<1

\ctikzset{bipoles/loudspeaker/height/.initial=.8}
\ctikzset{bipoles/loudspeaker/depth/.initial=.3}
\ctikzset{bipoles/loudspeaker/width/.initial=.8}
\ctikzset{bipoles/mic/height/.initial=1.2}
\ctikzset{bipoles/mic/depth/.initial=.1}
\ctikzset{bipoles/mic/width/.initial=.8}%
\ctikzset{bipoles/tlmic/width/.initial=.5}% it MUST be mic width *5/8
\ctikzset{bipoles/mic/bar thickness/.initial=1}

% arresters, fuses, lamps, etc

\ctikzset{bipoles/european gas filled surge arrester/height/.initial=.30}
\ctikzset{bipoles/european gas filled surge arrester/width/.initial=.80}
\ctikzset{bipoles/european gas filled surge arrester/inside/.initial=.30}
\ctikzset{bipoles/american gas filled surge arrester/height/.initial=.60}
\ctikzset{bipoles/american gas filled surge arrester/width/.initial=.60}
\ctikzset{bipoles/american gas filled surge arrester/inside/.initial=.15}
\ctikzset{bipoles/american gas filled surge arrester/dot x/.initial=.25}
\ctikzset{bipoles/american gas filled surge arrester/dot y/.initial=.45}
% fuses: normal, asymmetric, wiggle
\ctikzset{bipoles/american gas filled surge arrester/size/.initial=.1}
\ctikzset{bipoles/fuse/height/.initial=.20}
\ctikzset{bipoles/fuse/width/.initial=.50}
\ctikzset{bipoles/afuse/height/.initial=.20}
\ctikzset{bipoles/afuse/width/.initial=.50}
\ctikzset{bipoles/lamp/height/.initial=.60}
\ctikzset{bipoles/wfuse/height/.initial=.20}
\ctikzset{bipoles/wfuse/width/.initial=.50}
\ctikzset{bipoles/wfuse/shape/.initial=ocirc}
\newif\ifpgf@circ@wfuse@dots\pgf@circ@wfuse@dotstrue
\ctikzset{bipoles/wfuse/dots/.is choice}
\ctikzset{bipoles/wfuse/dots/.is if=pgf@circ@wfuse@dots}
%
\ctikzset{bipoles/lamp/width/.initial=.60}
\ctikzset{bipoles/bulb/height/.initial=.8}
\ctikzset{bipoles/bulb/width/.initial=.8}
\ctikzset{bipoles/squid/height/.initial=.60}
\ctikzset{bipoles/squid/width/.initial=.60}
\ctikzset{bipoles/barrier/height/.initial=.60}
\ctikzset{bipoles/barrier/width/.initial=.60}
\ctikzset{bipoles/openbarrier/gap/.initial=0.5}
\ctikzset{bipoles/thermocouple/height/.initial=.250}
\ctikzset{bipoles/thermocouple/height 2/.initial=.60}
\ctikzset{bipoles/thermocouple/width/.initial=.140}
\newif\ifpgf@circuit@europeangfsurgearrester
\ctikzset{gas filled surge arrester choice/.is choice}
\ctikzset{gas filled surge arrester choice/european/.code= {\pgf@circuit@europeangfsurgearrestertrue}}
\ctikzset{gas filled surge arrester choice/american/.code= {\pgf@circuit@europeangfsurgearresterfalse}}

\tikzset{american gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=american}}
\tikzset{european gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=european}}
%%>>>

%% Node shapes for miscellaneous symbols %<<<
%% loudspeaker and microphone

\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/loudspeaker/depth}}
{loudspeaker}
{\ctikzvalof{bipoles/loudspeaker/height}}
{\ctikzvalof{bipoles/loudspeaker/width}}{

    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{.4\pgf@circ@res@up}}
    {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgfpathmoveto{\pgfpoint{0.5\pgf@circ@res@left}{.4\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0.8\pgf@circ@res@left}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0.8\pgf@circ@res@right}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0.5\pgf@circ@res@right}{.4\pgf@circ@res@up}}
    \pgfpathclose
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgf@circ@draworfill
}

\def\pgf@circ@draw@mic@bar#1{%relative length of the bar
    \pgfsetroundcap
    \pgfsetlinewidth{\ctikzvalof{bipoles/mic/bar thickness}\pgflinewidth}%
    % adjust the vertical position; the symbol looks better if the circle touch the bar
    \pgfpathmoveto{\pgfpoint{#1\pgf@circ@res@left}{\pgf@circ@res@up+0.4\pgflinewidth}}
    \pgfpathlineto{\pgfpoint{#1\pgf@circ@res@right}{\pgf@circ@res@up+0.4\pgflinewidth}}
    \pgfusepath{draw}
}

\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/mic/depth}}
{mic}
{\ctikzvalof{bipoles/mic/height}}
{\ctikzvalof{bipoles/mic/width}}{

    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathcircle{\pgfpoint{0pt}{.6\pgf@circ@res@up}}{.4\pgf@circ@res@up}
        \pgf@circ@draworfill
        \pgf@circ@draw@mic@bar{.6}
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{-.2\pgf@circ@res@up}{0pt}}
    % 0.25358 is 0.6-0.4*cos(30)
    \pgfpathlineto{\pgfpoint{-.2\pgf@circ@res@up}{.25358\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{.2\pgf@circ@res@up}{.25358\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{.2\pgf@circ@res@up}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/tlmic/width}}
{tlmic}
{\ctikzvalof{bipoles/tlmic/width}}
{\ctikzvalof{bipoles/tlmic/width}}{

    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathcircle{\pgfpoint{0pt}{0pt}}{\pgf@circ@res@up}
    \pgf@circ@draworfill
    \pgf@circ@draw@mic@bar{1}
}

%% european gas filled surge arrester
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/european gas filled surge arrester/height}}
{european gas filled surge arrester}
{\ctikzvalof{bipoles/european gas filled surge arrester/height}}
{\ctikzvalof{bipoles/european gas filled surge arrester/width}}
{

    \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgf@circ@draworfill

    \pgfscope
        \pgfsetarrowsend{latexslim}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/european gas filled surge arrester/inside}\pgf@circ@res@left}{0pt}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfusepath{draw}

    \endpgfscope
}

%% american gas filled surge arrester
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/american gas filled surge arrester/height}}
{american gas filled surge arrester}
{\ctikzvalof{bipoles/american gas filled surge arrester/height}}
{\ctikzvalof{bipoles/american gas filled surge arrester/width}}{

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

    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathcircle{\pgfpointorigin}{.9\pgf@circ@res@up}
        \pgf@circ@draworfill
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}

    \pgfscope
        \pgfsetarrowsend{latex}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/american gas filled surge arrester/inside}\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfusepath{draw}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/american gas filled surge arrester/inside}\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgfusepath{draw}
    \endpgfscope{}

    \pgfpathcircle{\pgfpoint{\ctikzvalof{bipoles/american gas filled surge arrester/dot x}\pgf@circ@res@left}{\ctikzvalof{bipoles/american gas filled surge arrester/dot y}\pgf@circ@res@down}}{\ctikzvalof{bipoles/american gas filled surge arrester/size}\pgf@circ@res@down}
    \pgfusepath{fill}
}

%% thermocouple
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/thermocouple/height 2}}
{thermocouple}
{\ctikzvalof{bipoles/thermocouple/height}}
{\ctikzvalof{bipoles/thermocouple/width}}
{
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@down}}
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathlineto{\pgfpoint{0}{\pgf@circ@res@down}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{0}{\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{.5\pgf@circ@res@down}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfusepath{draw}
}
%% fuse
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/fuse/height}}
{fuse}
{\ctikzvalof{bipoles/fuse/height}}
{\ctikzvalof{bipoles/fuse/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfusepath{draw}

}
%% asymmetric fuse
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/afuse/height}}
{afuse}
{\ctikzvalof{bipoles/afuse/height}}
{\ctikzvalof{bipoles/afuse/width}}
{
    \pgfscope
        \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgf@circ@draworfill
    \endpgfscope

    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
    \pgfusepath{draw}

    \pgfpathrectanglecorners{\pgfpoint{.7\pgf@circ@res@right}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
    \pgf@circ@fill@strokecolor
    \pgfusepath{stroke,fill}
}
%% wiggly fuse
\pgfcircdeclarebipolescaled{misc}
{
    \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
    \savedmacro{\cshape}{\def\cshape{\ctikzvalof{bipoles/wfuse/shape}}}
}
{\ctikzvalof{bipoles/wfuse/height}}
{wfuse}
{\ctikzvalof{bipoles/wfuse/height}}
{\ctikzvalof{bipoles/wfuse/width}}
{
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpatharc{0}{180}{.5\pgf@circ@res@left}
    \pgfpatharc{0}{-180}{.5\pgf@circ@res@left}
    \pgfusepath{draw}
    \ifpgf@circ@wfuse@dots
        \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-left}{\pgfusepath{draw}}
        \pgftransformshift{\pgfpoint{2\pgf@circ@res@right}{0pt}}
        \pgfnode{\cshape}{center}{}{\thisshape-right}{\pgfusepath{draw}}
    \fi
}
%% SQUID added by Cor Molenaar 5 March 2010
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/squid/height}}
{squid}
{\ctikzvalof{bipoles/squid/height}}
{\ctikzvalof{bipoles/squid/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\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
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/barrier/height}}
{barrier}
{\ctikzvalof{bipoles/barrier/height}}
{\ctikzvalof{bipoles/barrier/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\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}
}

%
% open version of the barrier symbol
% suggested by Radványi Patrik Tamás <patrikradvanyi@gmail.com>
%
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/barrier/height}}
{openbarrier}
{\ctikzvalof{bipoles/barrier/height}}
{\ctikzvalof{bipoles/barrier/width}}
{
    % this is set with normal wire linewidth
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/openbarrier/gap}*\pgf@circ@res@left}{0pt}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/openbarrier/gap}*\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}

    % do the cross part
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \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}
}
%% Lamp
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/lamp/height}}
{lamp}
{\ctikzvalof{bipoles/lamp/height}}
{\ctikzvalof{bipoles/lamp/width}}
{
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}

    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \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}
}

%% bulb
\pgfcircdeclarebipolescaled{misc}
{}
{\ctikzvalof{bipoles/bulb/height}}
{bulb}
{\ctikzvalof{bipoles/bulb/height}}
{\ctikzvalof{bipoles/bulb/width}}
{%
    \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{0.8\pgf@circ@res@up}}{\pgfpoint{0.8\pgf@circ@res@left}{0}}
    \pgf@circ@draworfill
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpathlineto{\pgfpoint{0.4\pgf@circ@res@left}{\pgf@circ@res@zero}}
    \pgfpatharc{0}{-180}{0.4*\pgf@circ@res@left}
    \pgfsetbeveljoin
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
    \pgfusepath{draw}
}% %>>>

%% Path definitions for Miscellaneous%<<<

\pgfcirc@activate@bipole@simple{l}{lamp}
\pgfcirc@activate@bipole@simple{l}{bulb}
\pgfcirc@activate@bipole@simple{l}{squid}
\pgfcirc@activate@bipole@simple{l}{barrier}
\pgfcirc@activate@bipole@simple{l}{openbarrier}
\pgfcirc@activate@bipole@simple{l}{thermocouple}
\pgfcirc@activate@bipole@simple{l}{fuse}
\pgfcirc@activate@bipole{l}{afuse}{afuse}{asymmetric fuse}
\pgfcirc@style@to@style{asymmetric fuse}{afuse}
\pgfcirc@activate@bipole@simple{l}{wfuse}
\pgfcirc@activate@bipole{l}{wfuse}{wfuse}{wiggly fuse}
\def\pgf@circ@gfsurgearrester@path#1{\ifpgf@circuit@europeangfsurgearrester\pgf@circ@europeangfsurgearrester@path{#1}\else\pgf@circ@americangfsurgearrester@path{#1}\fi}
\pgfcirc@activate@bipole{l}{europeangfsurgearrester}{european gas filled surge arrester}{european gas filled surge arrester}
\pgfcirc@activate@bipole{l}{americangfsurgearrester}{american gas filled surge arrester}{american gas filled surge arrester}
\pgfcirc@path@to@style{l}{gfsurgearrester}{gas filled surge arrester}{}
\pgfcirc@path@to@style{l}{gfsurgearrester}{gf surge arrester}{}
\pgfcirc@activate@bipole@simple{l}{mic}
\pgfcirc@activate@bipole@simple{l}{tlmic}
\pgfcirc@activate@bipole@simple{l}{loudspeaker}
% %>>>

%% Buzzer and reverse buzzer %<<<
\ctikzset{bipoles/buzzer/height/.initial=0.6}
\ctikzset{bipoles/buzzer/width/.initial=.4}%
\ctikzset{bipoles/buzzer/span/.initial=.6}%

\pgfcircdeclarebipolescaled{misc}
{}
{0}
{buzzer}
{\ctikzvalof{bipoles/buzzer/height}}
{\ctikzvalof{bipoles/buzzer/width}}{
    % this is the height of the semicircle
    \pgf@circ@res@other=\dimexpr\pgf@circ@res@up-\pgf@circ@res@right\relax
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@other}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@other}}
        \pgfpatharc{0}{180}{\pgf@circ@res@right}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@left}{\pgf@circ@res@other}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@right}{\pgf@circ@res@other}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}
\pgfcirc@activate@bipole@simple{l}{buzzer}
%
\pgfcircdeclarebipolescaled{misc}
{}
{0}
{rbuzzer}
{\ctikzvalof{bipoles/buzzer/height}}
{\ctikzvalof{bipoles/buzzer/width}}{
    % this is the height of the semicircle
    \pgf@circ@res@other=\dimexpr\pgf@circ@res@up-\pgf@circ@res@right\relax
    % this is the height where the pins touch the semicircle
    \pgfmathsetlength\pgf@circ@res@temp{\pgf@circ@res@up-
        \pgf@circ@res@right*sqrt(1-\ctikzvalof{bipoles/buzzer/span}*\ctikzvalof{bipoles/buzzer/span})}
    \pgfscope
        \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpatharc{0}{-180}{\pgf@circ@res@right}
        \pgfpathclose
        \pgf@circ@draworfill
    \endpgfscope
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@left}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@left}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfpathmoveto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@right}{\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\ctikzvalof{bipoles/buzzer/span}*\pgf@circ@res@right}{0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
    \pgfusepath{draw}
}
\pgfcirc@activate@bipole@simple{l}{rbuzzer}
% %>>>

% end of pgfcircbipoles.tex
% vim: set fdm=marker fmr=%<<<,%>>>:
