Body diode fill/stroke option for transistors

circuitikz

I need to change the format of body diodes in a given transistor, such that I can change it into a filled or stroked one, but I haven't found any documentation from the circuitikz package to do that.

I know that, for a filled body diode, I can fill it, but when a transistor circle is included, it fills the whole circle.

Example code:

\documentclass[]{standalone}
\usepackage[americanvoltages]{circuitikz}

\begin{document}
 \begin{tikzpicture}
    \draw[] 
    (0,0) to[D] ++(0,-1.25)
    (2,0) to[D*] ++(0,-1.25)
    (4,0) to[D-] ++(0,-1.25)

    (0,-2) node[nigfete,bodydiode](){}
    (2,-2) node[nigfete,bodydiode,fill=black](){}
    (4,-2) node[nigfete,bodydiode,tr circle,fill=black](){}
    ;
 \end{tikzpicture}
\end{document}

After compilation, I get this:

example code

Best Answer

The problem with your third example is that the fill parameter acts on every shape drawn, including the surrounding circle.

The diode in the transistor is drawn with the shape in force (full diodes, or empty diodes, or stroke diodes) at the moment of the drawing. Thankfully, using the scoping properties, you can change them locally:

\documentclass[border=2.78mm]{standalone}
\usepackage[americanvoltages]{circuitikz}

\begin{document}
 \begin{tikzpicture}
    \draw[]
    (0,0) to[D] ++(0,-1.25)
    node[nigfete,bodydiode, anchor=D](){}
    (2,0) to[D*] ++(0,-1.25)
    node[nigfete,bodydiode,stroke diodes, anchor=D](){}
    (4,0) to[D-] ++(0,-1.25)
    node[nigfete,bodydiode,tr circle,full diodes, anchor=D](){}
    ;
 \end{tikzpicture}
\end{document}

enter image description here

You can change other characteristics of the body diode by looking at "Transistor bodydiode customization", around page 122 in a recent manual.

\documentclass[border=2.78mm]{standalone}
\usepackage[americanvoltages]{circuitikz}

\begin{document}
 \begin{tikzpicture}
    \draw[]
    (0,0) to[D] ++(0,-1.25)
    node[nigfete,bodydiode, anchor=D](){}
    (2,0) to[D*] ++(0,-1.25)
    node[nigfete,bodydiode,stroke diodes, anchor=D](){}
    (4,0) to[D-] ++(0,-1.25)
    node[nigfete,bodydiode,tr circle,empty diodes, anchor=D,
        circuitikz/transistor bodydiode/color=red](){}
    ;
 \end{tikzpicture}
\end{document}

enter image description here

(but notice that locally enacted full diodes with color changes do not work correctly: that could be a bug, see https://github.com/circuitikz/circuitikz/issues/794).

Related Question