From 8e8c05aa6d6db2c28633a8924de4a0b941b52030 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sat, 13 Jul 2019 21:39:36 +0000
Subject: circuitikz (13jul19)

git-svn-id: svn://tug.org/texlive/trunk@51634 c570f23f-e606-0410-a88d-b1316a301751
---
 .../tex/generic/circuitikz/pgfcirctripoles.tex     | 462 ++++++++++++---------
 1 file changed, 273 insertions(+), 189 deletions(-)

(limited to 'Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex')

diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex
index bfcffe9d359..c64f400d214 100644
--- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex
+++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirctripoles.tex
@@ -1644,13 +1644,15 @@
         \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgfhorizontaltransformationadjustment*.5*\pgflinewidth}{\pgf@circ@res@up+\pgf@circ@res@down}}
         \pgfusepath{draw}
     \fi
-    \pgfpathcircle{\pgfpoint
-        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left - \pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgf@circ@Rlen}
-    {\pgf@circ@res@up+\pgf@circ@res@down}}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgf@circ@Rlen}
-    \ifpgf@circuit@pmos@emptycircle
-        \pgfsetfillcolor{white}
+        \ifpgf@circuit@pmos@nocircle\else
+        \pgfpathcircle{\pgfpoint
+            {\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left - \pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgf@circ@Rlen}
+        {\pgf@circ@res@up+\pgf@circ@res@down}}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgf@circ@Rlen}
+        \ifpgf@circuit@pmos@emptycircle
+            \pgfsetfillcolor{white}
+        \fi
+        \pgfusepath{draw,fill}
     \fi
-    \pgfusepath{draw,fill}
 }
 
 %% HEMT FET Transistor
@@ -4193,21 +4195,21 @@
 % Draw tube outline
 \def\pgf@circ@tubes@drawtube{%
 	\ifdim\ctikzvalof{tubes/width}pt>\ctikzvalof{tubes/height}pt\relax
-		\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}}
-		\pgfutil@tempdima=\pgf@circ@res@right
-		\advance\pgfutil@tempdima by -\pgf@circ@res@up
-		\pgfpathlineto{\pgfpoint{\pgfutil@tempdima}{\pgf@circ@res@up}}
-		\pgfpatharc{90}{-90}{\pgf@circ@res@up}
-		\pgfpathlineto{\pgfpoint{-\pgfutil@tempdima}{-\pgf@circ@res@up}}
-		\pgfpatharc{270}{90}{\pgf@circ@res@up}
+	\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}}
+	\pgfutil@tempdima=\pgf@circ@res@right
+	\advance\pgfutil@tempdima by -\pgf@circ@res@up
+	\pgfpathlineto{\pgfpoint{\pgfutil@tempdima}{\pgf@circ@res@up}}
+	\pgfpatharc{90}{-90}{\pgf@circ@res@up}
+	\pgfpathlineto{\pgfpoint{-\pgfutil@tempdima}{-\pgf@circ@res@up}}
+	\pgfpatharc{270}{90}{\pgf@circ@res@up}
 	\else
-		\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{0pt}}
-		\pgfutil@tempdima=\pgf@circ@res@up
-		\advance\pgfutil@tempdima by -\pgf@circ@res@right
-		\pgfpathlineto{\pgfpoint{-\pgf@circ@res@right}{\pgfutil@tempdima}}
-		\pgfpatharc{180}{0}{\pgf@circ@res@right}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgfutil@tempdima}}
-		\pgfpatharc{180}{0}{-\pgf@circ@res@right}
+	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{0pt}}
+	\pgfutil@tempdima=\pgf@circ@res@up
+	\advance\pgfutil@tempdima by -\pgf@circ@res@right
+	\pgfpathlineto{\pgfpoint{-\pgf@circ@res@right}{\pgfutil@tempdima}}
+	\pgfpatharc{180}{0}{\pgf@circ@res@right}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgfutil@tempdima}}
+	\pgfpatharc{180}{0}{-\pgf@circ@res@right}
 	\fi
 	\pgfpathclose
 }
@@ -4218,52 +4220,52 @@
 %% \pgfcircdeclaretube{tube name}{grid anchors}{grid drawing code}
 \long\def\pgfcircdeclaretube#1#2#3{%
 	\pgfdeclareshape{#1}{
-	    \anchor{center}{
-	        \pgfpointorigin
-	    }
-	    \savedanchor\northwest{%
-	        \pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
+		\anchor{center}{
+			\pgfpointorigin
+		}
+		\savedanchor\northwest{%
+			\pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
 			\pgf@circ@res@right=\ctikzvalof{tubes/width}\pgf@circ@Rlen
 			% x and y should be half the Rlen
-	        \pgf@y=\pgf@circ@res@up
-	        \pgf@y=.5\pgf@y
-	        \pgf@x=-\pgf@circ@res@right
-	        \pgf@x=.5\pgf@x
-	    }
+			\pgf@y=\pgf@circ@res@up
+			\pgf@y=.5\pgf@y
+			\pgf@x=-\pgf@circ@res@right
+			\pgf@x=.5\pgf@x
+		}
 		\anchor{north} {%
 			\northwest
 			\pgf@x=0pt
 		}
-	    \anchor{east}{%
-	        \northwest
-	        \pgf@x=-\pgf@x
-	        \pgf@y=0pt
-	    }
+		\anchor{east}{%
+			\northwest
+			\pgf@x=-\pgf@x
+			\pgf@y=0pt
+		}
 		\anchor{south}{%
-	        \northwest
-	        \pgf@y=-\pgf@y
+			\northwest
+			\pgf@y=-\pgf@y
 			\pgf@x=0pt
 		}
-	    \anchor{west}{%
-	        \northwest
-	        \pgf@y=0pt
-	    }
-	    \anchor{north west}{%
-	        \northwest
-	    }
-	    \anchor{north east}{%
-	        \northwest
-	        \pgf@x=-\pgf@x
-	    }
-	    \anchor{south east}{
-	        \northwest
-	        \pgf@x=-\pgf@x
-	        \pgf@y=-\pgf@y
-	    }
-	    \anchor{south west}{
-	        \northwest
-	        \pgf@y=-\pgf@y
-	    }
+		\anchor{west}{%
+			\northwest
+			\pgf@y=0pt
+		}
+		\anchor{north west}{%
+			\northwest
+		}
+		\anchor{north east}{%
+			\northwest
+			\pgf@x=-\pgf@x
+		}
+		\anchor{south east}{
+			\northwest
+			\pgf@x=-\pgf@x
+			\pgf@y=-\pgf@y
+		}
+		\anchor{south west}{
+			\northwest
+			\pgf@y=-\pgf@y
+		}
 		\anchor{anode} {%
 			\northwest
 			\pgf@x=0pt
@@ -4295,85 +4297,85 @@
 			\pgf@x=-\pgfmathresult\pgf@x
 			\pgf@y=-\pgf@y
 		}
-
+		
 		% Extra anchors
 		#2
-
+		
 		\backgroundpath{
 			\pgfscope
-				% Line width for tripoles
-				\pgfsetlinewidth{\ctikzvalof{tripoles/thickness}\pgflinewidth}
-	
-				% Setup to draw tube
-				\pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
-				\pgf@circ@res@right=\ctikzvalof{tubes/width}\pgf@circ@Rlen
-				\pgf@circ@res@up=\ctikzvalof{tubes/tube radius}\pgf@circ@res@up
-				\pgf@circ@res@right=\ctikzvalof{tubes/tube radius}\pgf@circ@res@right
-	
-				% Tube fill color (if any)
-				\ifx\tikz@fillcolor\pgfutil@empty
-				\else
-					\pgfscope
-						\pgfsetfillcolor{\tikz@fillcolor}
-						\pgf@circ@tubes@drawtube
-						\pgfusepath{fill}
-					\endpgfscope
-				\fi
-	
-				% Tube outline
-				\pgf@circ@tubes@drawtube
-
-				% Setup to draw grid, filament, anode and cathode
-				\pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
-				\pgf@circ@res@right=\ctikzvalof{tubes/width}\pgf@circ@Rlen
-				\pgf@circ@res@up=0.5\pgf@circ@res@up
-				\pgf@circ@res@right=0.5\pgf@circ@res@right
-
-				% Grid drawing
-				#3
-				
-				% Filament (is not drawn by default)
-				\ifpgf@circuit@tubes@filament
-					\pgf@circ@res@temp=-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up
-					\advance\pgf@circ@res@temp by -\ctikzvalof{tubes/filament distance}\pgf@circ@res@up
-					\pgfmathparse{(\ctikzvalof{tubes/tube radius}*sin(\ctikzvalof{tubes/filament angle})}
-					\pgf@xa=\pgfmathresult\pgf@circ@res@right
-					\pgfmathparse{\ctikzvalof{tubes/tube radius}+\ctikzvalof{tubes/tube radius}*cos(\ctikzvalof{tubes/filament angle}}
-					\pgf@ya=\pgfmathresult\pgf@circ@res@up
-					\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@temp}}
-					\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
-					\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@circ@res@up}}
-					\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@temp}}
-					\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
-					\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@circ@res@up}}
-					\pgf@circuit@tubes@filamentfalse
-				\fi
-	
-				% Anode (or plate)
-				\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} % north
-				\pgfpathlineto{\pgfpoint{0pt}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
-				\pgfpathmoveto{\pgfpoint{-\ctikzvalof{tubes/anode width}\pgf@circ@res@right}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
-				\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/anode width}\pgf@circ@res@right}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
-	
-				% Cathode
-				\ifpgf@circuit@tubes@nocathode
-					\pgf@circuit@tubes@nocathodefalse
-				\else
-					\pgfsetcornersarced{\pgfpoint{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}}
-					\pgfpathmoveto{\pgfpoint{-\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\pgf@circ@res@up}}
-					\pgfpathlineto{\pgfpoint{-\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up}}
-					\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up}}
-					\ifpgf@circuit@tubes@fullcathode
-						\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\pgf@circ@res@up}}
-						\pgf@circuit@tubes@fullcathodefalse
-					\else
-						\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up-\ctikzvalof{tubes/cathode right extend}\pgf@circ@res@up}}
-					\fi
-				\fi
-
-				% Draw the background	
-				\pgfusepath{draw}
-
+			% Line width for tripoles
+			\pgfsetlinewidth{\ctikzvalof{tripoles/thickness}\pgflinewidth}
+			
+			% Setup to draw tube
+			\pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
+			\pgf@circ@res@right=\ctikzvalof{tubes/width}\pgf@circ@Rlen
+			\pgf@circ@res@up=\ctikzvalof{tubes/tube radius}\pgf@circ@res@up
+			\pgf@circ@res@right=\ctikzvalof{tubes/tube radius}\pgf@circ@res@right
+			
+			% Tube fill color (if any)
+			\ifx\tikz@fillcolor\pgfutil@empty
+			\else
+			\pgfscope
+			\pgfsetfillcolor{\tikz@fillcolor}
+			\pgf@circ@tubes@drawtube
+			\pgfusepath{fill}
+			\endpgfscope
+			\fi
+			
+			% Tube outline
+			\pgf@circ@tubes@drawtube
+			
+			% Setup to draw grid, filament, anode and cathode
+			\pgf@circ@res@up=\ctikzvalof{tubes/height}\pgf@circ@Rlen
+			\pgf@circ@res@right=\ctikzvalof{tubes/width}\pgf@circ@Rlen
+			\pgf@circ@res@up=0.5\pgf@circ@res@up
+			\pgf@circ@res@right=0.5\pgf@circ@res@right
+			
+			% Grid drawing
+			#3
+			
+			% Filament (is not drawn by default)
+			\ifpgf@circuit@tubes@filament
+			\pgf@circ@res@temp=-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up
+			\advance\pgf@circ@res@temp by -\ctikzvalof{tubes/filament distance}\pgf@circ@res@up
+			\pgfmathparse{(\ctikzvalof{tubes/tube radius}*sin(\ctikzvalof{tubes/filament angle})}
+			\pgf@xa=\pgfmathresult\pgf@circ@res@right
+			\pgfmathparse{\ctikzvalof{tubes/tube radius}+\ctikzvalof{tubes/tube radius}*cos(\ctikzvalof{tubes/filament angle}}
+			\pgf@ya=\pgfmathresult\pgf@circ@res@up
+			\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@temp}}
+			\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@ya}}
+			\pgfpathlineto{\pgfpoint{-\pgf@xa}{-\pgf@circ@res@up}}
+			\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@temp}}
+			\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@ya}}
+			\pgfpathlineto{\pgfpoint{\pgf@xa}{-\pgf@circ@res@up}}
+			\pgf@circuit@tubes@filamentfalse
+			\fi
+			
+			% Anode (or plate)
+			\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} % north
+			\pgfpathlineto{\pgfpoint{0pt}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
+			\pgfpathmoveto{\pgfpoint{-\ctikzvalof{tubes/anode width}\pgf@circ@res@right}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
+			\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/anode width}\pgf@circ@res@right}{\ctikzvalof{tubes/anode distance}\pgf@circ@res@up}}
+			
+			% Cathode
+			\ifpgf@circuit@tubes@nocathode
+			\pgf@circuit@tubes@nocathodefalse
+			\else
+			\pgfsetcornersarced{\pgfpoint{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}}
+			\pgfpathmoveto{\pgfpoint{-\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\pgf@circ@res@up}}
+			\pgfpathlineto{\pgfpoint{-\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up}}
+			\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up}}
+			\ifpgf@circuit@tubes@fullcathode
+			\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\pgf@circ@res@up}}
+			\pgf@circuit@tubes@fullcathodefalse
+			\else
+			\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up-\ctikzvalof{tubes/cathode right extend}\pgf@circ@res@up}}
+			\fi
+			\fi
+			
+			% Draw the background    
+			\pgfusepath{draw}
+			
 			\endpgfscope
 		}
 	}
@@ -4383,10 +4385,14 @@
 
 \pgfcircdeclaretube{triode}
 {
-	\anchor{grid} {%
-        \northwest
+	\anchor{grid} {% should not be used
+		\northwest
 		\pgf@y=\ctikzvalof{tubes/grid shift}\pgf@y
-    }
+	}
+	\anchor{control} {%
+		\northwest
+		\pgf@y=\ctikzvalof{tubes/grid shift}\pgf@y
+	}
 }
 {
 	% Grid protrusion
@@ -4397,40 +4403,47 @@
 	% Grid dashes: calculations
 	\pgf@xb=2\pgf@circ@res@right
 	\pgf@circ@res@step=\ctikzvalof{tubes/tube radius}\pgf@xb
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
-	\multiply\@tempcnta by 2\relax
-	\advance\@tempcnta by 1\relax
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
+	\multiply\pgf@circ@count@a by 2\relax
+	\advance\pgf@circ@count@a by 1\relax
 	\advance\pgf@circ@res@step by -\pgf@xa
-	\divide\pgf@circ@res@step by \@tempcnta
+	\divide\pgf@circ@res@step by \pgf@circ@count@a
 	% Grid dashes: draw
 	\pgf@circ@res@temp=\pgf@xa
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}
 	\loop
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\ctikzvalof{tubes/grid shift}\pgf@circ@res@up}}
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{\ctikzvalof{tubes/grid shift}\pgf@circ@res@up}}
-		\advance\@tempcnta by-1
-		\ifnum\@tempcnta>0\relax
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\ctikzvalof{tubes/grid shift}\pgf@circ@res@up}}
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{\ctikzvalof{tubes/grid shift}\pgf@circ@res@up}}
+	\advance\pgf@circ@count@a by-1
+	\ifnum\pgf@circ@count@a>0\relax
 	\repeat
 }
 
 \pgfcircdeclaretube{tetrode}
 {
-	\anchor{grid} {%
-        \northwest
+	\anchor{grid} {% should not be used
+		\northwest
 		\pgfutil@tempdima=\pgf@y
 		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
 		\pgf@y=0.5\pgf@y
 		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
-    }
+	}
+	\anchor{control} {%
+		\northwest
+		\pgfutil@tempdima=\pgf@y
+		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
+		\pgf@y=0.5\pgf@y
+		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
+	}
 	\anchor{screen} {%
-        \northwest
+		\northwest
 		\pgfutil@tempdima=\pgf@y
 		\pgf@y=\ctikzvalof{tubes/grid separation}\pgf@y
 		\pgf@y=0.5\pgf@y
 		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
-    }
+	}
 }
 {
 	% Grid x/y points
@@ -4450,44 +4463,50 @@
 	% Grid dashes: calculations
 	\pgf@xb=2\pgf@circ@res@right
 	\pgf@circ@res@step=\ctikzvalof{tubes/tube radius}\pgf@xb
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
-	\multiply\@tempcnta by 2\relax
-	\advance\@tempcnta by 1\relax
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
+	\multiply\pgf@circ@count@a by 2\relax
+	\advance\pgf@circ@count@a by 1\relax
 	\advance\pgf@circ@res@step by -\pgf@xa
-	\divide\pgf@circ@res@step by \@tempcnta
+	\divide\pgf@circ@res@step by \pgf@circ@count@a
 	% Grid dashes: draw
 	\pgf@circ@res@temp=\pgf@xa
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}
 	\loop
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima}}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdima}}
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdimb}}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdimb}}
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\advance\@tempcnta by-1
-		\ifnum\@tempcnta>0\relax
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdima}}
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdimb}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdimb}}
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\advance\pgf@circ@count@a by-1
+	\ifnum\pgf@circ@count@a>0\relax
 	\repeat
 }
 
 \pgfcircdeclaretube{pentode}
 {
-	\anchor{grid} {%
-        \northwest
+	\anchor{grid} {% should not be used
+		\northwest
 		\pgfutil@tempdima=\pgf@y
 		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
 		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
-    }
+	}
+	\anchor{control} {%
+		\northwest
+		\pgfutil@tempdima=\pgf@y
+		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
+		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
+	}
 	\anchor{screen} {%
-        \northwest
+		\northwest
 		\pgf@y=\ctikzvalof{tubes/grid shift}\pgf@y
-    }
+	}
 	\anchor{suppressor} {%
-        \northwest
+		\northwest
 		\pgfutil@tempdima=\pgf@y
 		\pgf@y=\ctikzvalof{tubes/grid separation}\pgf@y
 		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
-    }
+	}
 }
 {
 	% Grid x/y points
@@ -4497,37 +4516,102 @@
 	\pgfutil@tempdimb=-\pgfutil@tempdima
 	\advance\pgfutil@tempdima by \ctikzvalof{tubes/grid shift}\pgf@circ@res@up
 	\advance\pgfutil@tempdimb by \ctikzvalof{tubes/grid shift}\pgf@circ@res@up
-	\@tempdimc=\ctikzvalof{tubes/grid shift}\pgf@circ@res@up
+	\pgf@circ@res@other=\ctikzvalof{tubes/grid shift}\pgf@circ@res@up
 	% Grid protrusion
 	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgfutil@tempdimb}}
 	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgfutil@tempdimb}}
 	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgfutil@tempdima}}
 	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgfutil@tempdima}}
-	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\@tempdimc}}
-	\pgfpathlineto{\pgfpoint{\pgf@xa}{\@tempdimc}}
+	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgf@circ@res@other}}
+	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@circ@res@other}}
+	% Grid dashes: calculations
+	\pgf@xb=2\pgf@circ@res@right
+	\pgf@circ@res@step=\ctikzvalof{tubes/tube radius}\pgf@xb
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
+	\multiply\pgf@circ@count@a by 2\relax
+	\advance\pgf@circ@count@a by 1\relax
+	\advance\pgf@circ@res@step by -\pgf@xa
+	\divide\pgf@circ@res@step by \pgf@circ@count@a
+	% Grid dashes: draw
+	\pgf@circ@res@temp=\pgf@xa
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}
+	\loop
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdima}}
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdimb}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdimb}}
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@other}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgf@circ@res@other}}
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\advance\pgf@circ@count@a by-1
+	\ifnum\pgf@circ@count@a>0\relax
+	\repeat
+}
+
+\pgfcircdeclaretube{pentode suppressor to cathode}
+{
+	\anchor{grid} {% should not be used
+		\northwest
+		\pgfutil@tempdima=\pgf@y
+		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
+		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
+	}
+	\anchor{control} {%
+		\northwest
+		\pgfutil@tempdima=\pgf@y
+		\pgf@y=-\ctikzvalof{tubes/grid separation}\pgf@y
+		\advance\pgf@y by \ctikzvalof{tubes/grid shift}\pgfutil@tempdima
+	}
+	\anchor{screen} {%
+		\northwest
+		\pgf@y=\ctikzvalof{tubes/grid shift}\pgf@y
+	}
+}
+{
+	% Grid x/y points
+	\pgf@xa=-\ctikzvalof{tubes/tube radius}\pgf@circ@res@right
+	\advance\pgf@xa by -\ctikzvalof{tubes/grid protrusion}\pgf@circ@res@right
+	\pgfutil@tempdima=\ctikzvalof{tubes/grid separation}\pgf@circ@res@up
+	\pgfutil@tempdimb=-\pgfutil@tempdima
+	\advance\pgfutil@tempdima by \ctikzvalof{tubes/grid shift}\pgf@circ@res@up
+	\advance\pgfutil@tempdimb by \ctikzvalof{tubes/grid shift}\pgf@circ@res@up
+	\pgf@circ@res@other=\ctikzvalof{tubes/grid shift}\pgf@circ@res@up
+	% Grid protrusion
+	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgfutil@tempdimb}}
+	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgfutil@tempdimb}}
+	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{\pgf@circ@res@other}}
+	\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@circ@res@other}}
 	% Grid dashes: calculations
 	\pgf@xb=2\pgf@circ@res@right
 	\pgf@circ@res@step=\ctikzvalof{tubes/tube radius}\pgf@xb
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
-	\multiply\@tempcnta by 2\relax
-	\advance\@tempcnta by 1\relax
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}  % dashes*2+1
+	\multiply\pgf@circ@count@a by 2\relax
+	\advance\pgf@circ@count@a by 1\relax
 	\advance\pgf@circ@res@step by -\pgf@xa
-	\divide\pgf@circ@res@step by \@tempcnta
+	\divide\pgf@circ@res@step by \pgf@circ@count@a
 	% Grid dashes: draw
 	\pgf@circ@res@temp=\pgf@xa
-	\@tempcnta=\ctikzvalof{tubes/grid dashes}
+	\pgf@circ@count@a=\ctikzvalof{tubes/grid dashes}
 	\loop
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima}}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdima}}
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdimb}}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdimb}}
-		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\@tempdimc}}
-		\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\@tempdimc}}
-		\advance\pgf@circ@res@temp by\pgf@circ@res@step
-		\advance\@tempcnta by-1
-		\ifnum\@tempcnta>0\relax
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\ifnum\pgf@circ@count@a>1\relax
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdimb}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdimb}}
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@other}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgf@circ@res@other}}
+	\fi
+	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@step}{\pgfutil@tempdima}}
+	\advance\pgf@circ@res@temp by\pgf@circ@res@step
+	\advance\pgf@circ@count@a by-1
+	\ifnum\pgf@circ@count@a>0\relax
 	\repeat
+	% Grid: connection from suppressor to cathode
+	\pgfsetcornersarced{\pgfpoint{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}{\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}}
+	\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{\pgfutil@tempdima-2*\ctikzvalof{tubes/grid separation}\pgf@circ@res@up}}
+	\pgfpathlineto{\pgfpoint{\ctikzvalof{tubes/cathode width}\pgf@circ@res@right-0.4142136*\ctikzvalof{tubes/cathode corners}\pgf@circ@res@right}{-\ctikzvalof{tubes/cathode distance}\pgf@circ@res@up-0.4142136*\ctikzvalof{tubes/cathode corners}\pgf@circ@res@up}}
+	
 }
 
 \endinput
-- 
cgit v1.2.3

