summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex')
-rw-r--r--graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex94
1 files changed, 94 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex
index fdaad445ce..724f5ee350 100644
--- a/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex
+++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex
@@ -443,6 +443,96 @@
}
}
+%% transistor arrow
+
+\def\pgf@circ@find@linescale{
+ % find the scale inverse of the scale factor: line width do not scale
+ % with scale=..., transform shape so we have to counteract it.
+ \iftikz@fullytransformed % this is true if `transform shape` is active
+ % from @Circumscribe https://tex.stackexchange.com/a/474035/38080
+ % Note that this trick is not working inside a `spy` environment...
+ \pgfgettransformentries{\scaleA}{\scaleB}{\scaleC}{\scaleD}{\whatevs}{\whatevs}%
+ \pgfmathsetmacro{\@@factor}{1.0/sqrt(abs(\scaleA*\scaleD-\scaleB*\scaleC))}%
+ \else
+ \pgfmathsetmacro{\@@factor}{1.0}
+ \fi
+}
+
+\pgfdeclareshape{trarrow}{%
+ % this arrow is only filled but grows with the linewidth, more or less
+ % like currarrow do
+ \savedanchor{\northeast}{%
+ \pgf@circ@res@step = \pgf@circ@Rlen
+ \pgf@circ@find@linescale
+ \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale}
+ \pgfpoint{0.7*\pgf@circ@res@step +0.5*\@@factor*\pgflinewidth}
+ {0.8*\pgf@circ@res@step+0.7593*\@@factor*\pgflinewidth}
+ }
+ % The arrow size should be more or less the same of a currarrow, which is
+ % both filled and stroke, for backward output compatibility (more or less)
+ %
+ % angle \beta W is \pgf@circ@Rlen/\ctikzvalof{current arrow scale}
+ % |-\__ currarrow as the tip at (W,0)
+ % | | and the upper tail at (-0.7*W, 0.8*W)
+ % | \__ it then "overshoot" do to the linew width L
+ % | \__ xangle \alpha
+ % ---0------->
+ %
+ % \beta = atan(0.7/0.8) \alpha=atan(0.8/1.7)
+ % tip overshoot is (L/2)/sin(\alpha) = 1.743*L only in x direction
+ % tail overshoot is -(L/2) in x, and (L/2)/sin(\beta) = 0.7539*L in y
+ %
+ \savedanchor{\northwest}{%
+ \pgf@circ@res@step = \pgf@circ@Rlen
+ \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale}
+ \pgf@circ@find@linescale
+ \pgfpoint{-0.7*\pgf@circ@res@step -0.5*\@@factor*\pgflinewidth}
+ {0.8*\pgf@circ@res@step+0.7593*\@@factor*\pgflinewidth}
+ }
+ \savedanchor{\tip}{%
+ \pgf@circ@res@step = \pgf@circ@Rlen
+ \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale}
+ \pgf@circ@find@linescale
+ \pgfpoint{\pgf@circ@res@step + 1.743*\@@factor*\pgflinewidth}{0pt}
+ }
+ \anchor{north}{\northeast\pgf@x=0cm\relax}
+ \anchor{east}{\northeast\pgf@y=0cm\relax}
+ \anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax}
+ \anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x}
+ \anchor{north east}{\northeast}
+ \anchor{north west}{\northeast\pgf@x=-\pgf@x}
+ \anchor{south east}{\northeast\pgf@y=-\pgf@y}
+ \anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x}
+ \anchor{center}{
+ \pgfpointorigin
+ }
+ \anchor{tip}{
+ \tip
+ }
+ \anchor{btip}{% this anchor is behind the tip of half a linewidth
+ \tip
+ \pgf@circ@find@linescale
+ \pgf@circ@res@temp=\@@factor\pgflinewidth
+ \advance\pgf@x by -.5\pgf@circ@res@temp
+ }
+ \behindforegroundpath{
+ \pgfscope
+ \northwest
+ \pgf@circ@res@up=\pgf@y
+ \pgf@circ@res@left=\pgf@x
+ \tip
+ \pgf@circ@res@step = \pgf@x
+ %
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
+ \pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}}
+ \pgfpathclose
+ \pgfsetcolor{\ctikzvalof{color}}
+ \pgfusepath{fill} % just fill
+ \endpgfscope
+ }
+}
%% Current arrow
@@ -506,6 +596,10 @@
\anchor{north west}{\northeast\pgf@x=-\pgf@x}
\anchor{south east}{\northeast\pgf@y=-\pgf@y}
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x}
+ \anchor{text}{% text centered above
+ \pgfpointorigin
+ \pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox}
+ }
\anchor{center}{
\pgfpointorigin
}