答案1
我创建了一个名为 的新组件pushed button
。我将pushbotton
底部复制并移动到\pgf@circ@res@temp
。
\documentclass{standalone}
\usepackage{circuitikz}
\makeatletter
%% Push Button
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/pushbutton/height 2}}{pushedbutton}{\ctikzvalof{bipoles/pushbutton/height}}{\ctikzvalof{bipoles/pushbutton/width}}{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgf@circ@res@temp=-\pgfkeysvalueof{/tikz/circuitikz/nodes width}\pgf@circ@Rlen
\advance\pgf@circ@res@temp by -2\pgfstartlinewidth
\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}}
}
\def\pgf@circ@pushedbutton@path#1{\pgf@circ@bipole@path{pushedbutton}{#1}}
\compattikzset{pushed button/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@pushedbutton@path, l=#1}}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,0) to[pushed button] (2,0);
\end{circuitikz}
\end{document}