我读了这篇小文章:http://www.elfsoft2000.com/projects/bipole.pdf以及本文提到的另外两个。我想创建一个符号用于我的论文和项目中。在我的国家,其中一些与欧洲或美国的不同,所以我决定自己制作它们。
我设法得到了两个罗马尼亚电路符号,如下所示:github.com/PopAdi/circuitikz-romanian-symbols
现在我必须做类似的事情:不是圆形,而是菱形。我该怎么做?我希望它们看起来像这里展示的那样:Circuitikz 美国控制电压标志
在我的代码中,对于带有圆圈的代码,我有:
\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0cm}{\ResUp}}{\pgfpoint{\ResRight}{0cm}}
我设法用这个制作了一个正方形:
\pgfpathrectanglecorners{\southwest}{\northeast}
但我真的不知道如何旋转那个正方形或用菱形替换它。你能帮我解决这个问题吗?谢谢!
编辑:我的代码如下所示:
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.markings}
\makeatletter
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\makeatother
\newlength{\ResUp}
\newlength{\ResRight}
\ctikzset{bipoles/romanianCCS/height/.initial=.60}
\ctikzset{bipoles/romanianCCS/width/.initial=.60}
\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/romanianCCS/height}}
{romanianCCS}
{\ctikzvalof{bipoles/romanianCCS/height}}
{\ctikzvalof{bipoles/romanianCCS/width}}
{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfextracty{\ResUp}{\northeast}
\pgfextractx{\ResRight}{\southwest}
%Desenam cerculetul
\pgfpathrectanglecorners{\southwest}{\northeast}
%First little arrow
\pgfmoveto{\pgfpoint{1.0\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.3\ResRight}{-0.25\ResUp}}
\pgfmoveto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.3\ResRight}{0.25\ResUp}}
%Second arrow
\pgfmoveto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{-1.0\ResRight}{0.0\ResUp}}
\pgfmoveto{\pgfpoint{0.0\ResRight}{0.25\ResUp}}
\pgflineto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgflineto{\pgfpoint{0.0\ResRight}{-0.25\ResUp}}
\pgfusepath{draw}
}
\def\romanianCCS#1{\TikzBipolePath{romanianCCS}{#1}}
\tikzset{romanianCCS/.style = {\circuitikzbasekey, /tikz/to path=\romanianCCS, l=#1}}
\begin{document}
\begin{center}
\begin{circuitikz}
\draw (0, 0)
to[romanianCCS, l=${j_1 = 4A}$, *-*] (4, 0);
\end{circuitikz}
\end{center}
\end{document}
将会得到以下结果:
我找到了解决方案!我这样做了:
\pgftransformrotate{-45}
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgftransformrotate{45}
而且效果非常好!
答案1
如果您想要菱形而不是菱形,您可以使用:
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.markings}
\makeatletter
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\makeatother
\newlength{\ResUp}
\newlength{\ResRight}
\ctikzset{bipoles/romanianCCS/height/.initial=.60}
\ctikzset{bipoles/romanianCCS/width/.initial=.60}
\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/romanianCCS/height}}
{romanianCCS}
{\ctikzvalof{bipoles/romanianCCS/height}}
{\ctikzvalof{bipoles/romanianCCS/width}}
{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfextracty{\ResUp}{\northeast}
\pgfextractx{\ResRight}{\southwest}
%Desenam cerculetul
\pgfpathmoveto{\pgfpoint{-\ResRight}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{-\ResUp}}
\pgfpathlineto{\pgfpoint{\ResRight}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{\ResUp}}
\pgfpathclose
%First little arrow
\pgfpathmoveto{\pgfpoint{1.0\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.3\ResRight}{-0.25\ResUp}}
\pgfpathmoveto{\pgfpoint{0.1\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.3\ResRight}{0.25\ResUp}}
%Second arrow
\pgfpathmoveto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{-1.0\ResRight}{0.0\ResUp}}
\pgfpathmoveto{\pgfpoint{0.0\ResRight}{0.25\ResUp}}
\pgfpathlineto{\pgfpoint{-0.2\ResRight}{0.0\ResUp}}
\pgfpathlineto{\pgfpoint{0.0\ResRight}{-0.25\ResUp}}
\pgfusepath{draw}
}
\def\romanianCCS#1{\TikzBipolePath{romanianCCS}{#1}}
\tikzset{romanianCCS/.style = {\circuitikzbasekey, /tikz/to path=\romanianCCS, l=#1}}
\begin{document}
\begin{center}
\begin{circuitikz}
\draw (0, 0)
to[romanianCCS, l=${j_1 = 4A}$, *-*] (4, 0);
\end{circuitikz}
\end{center}
\end{document}