[Tex/LaTex] Create custom symbol: diamond / rhombus shape

circuitikzpgfkeystikz-pgf

I read this little article: http://www.elfsoft2000.com/projects/bipole.pdf and the other two mentioned in this. I want to create a symbol to use in my papers and projects. In my country, some of them are different from the european or american ones so I decided to make them myself.

I managed to two Romanian circuit symbols as presented here: github.com/PopAdi/circuitikz-romanian-symbols

Now I have to do something similar: instead of a circle, there should be a diamond/rhombus. How can I achieve that? I want them to look like the ones presented here: Circuitikz american controlled voltage signs

In my code, for the one with the circle I have:

\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0cm}{\ResUp}}{\pgfpoint{\ResRight}{0cm}}

I managed to make a square with this:

\pgfpathrectanglecorners{\southwest}{\northeast}

But I really don't know how to rotate that square or to change it with a diamond. Can you help my figure this out?
Thanks!

Edit: my code looks like this:

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

which should give you the following result:

enter image description here

I found the solution! I did this:

\pgftransformrotate{-45}
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgftransformrotate{45}

And it's working great!

Best Answer

If you ever want a diamond instead of a rhombus, you can use:

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

demo

Related Question