Skip to content

Commit

Permalink
Add spark gap
Browse files Browse the repository at this point in the history
  • Loading branch information
Rmano committed May 24, 2024
1 parent 583764f commit 771c6c0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The major changes among the different CircuiTikZ versions are listed here. See <
- Added a Relais-Shape (contributed by [Jakob "DraUX" on GitHub](https://github.com/circuitikz/circuitikz/pull/795)
- Added a center tap anchor for tube's filament (suggested by [user bogger33 on GitHub](https://github.com/circuitikz/circuitikz/issues/792))
- Added neon lamps (two versions, suggested by [user bogger33 on GitHub](https://github.com/circuitikz/circuitikz/issues/793))
- Added a configurable spark gap (suggested by [user bogger33 on GitHub](https://github.com/circuitikz/circuitikz/issues/800))
- Fix a long-standing problem when [(locally) switching diode type](https://github.com/circuitikz/circuitikz/issues/794)

* Version 1.6.8 (2024-05-05)
Expand Down
24 changes: 22 additions & 2 deletions doc/circuitikzmanual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,10 @@ \subsection{Miscellaneous bipoles}
\circuitdescbip*{neonlampcc}{Neon lamp\footnotemark\ (double cathode style)}{}
\footnotetext{The neon lamps have been added in \texttt{v1.6.9} thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/793}{user bogger33 on GitHub}.}
\circuitdescbip*{neonlampac}{Neon lamp (anode and cathode style)}{}
\circuitdescbip*{sparkgap}{Spark gap\footnotemark (unenclosed)}{}
\footnotetext{The spark gap has been added in \texttt{v1.6.9} thanks to a suggestion by \href{https://github.com/circuitikz/circuitikz/issues/800}{user bogger33 on GitHub}.}
\circuitdescbip*[sparkgap]{sparkgap, sparkgap/circle}{Spark gap}{}
\circuitdescbip*[sparkgap]{sparkgap, sparkgap/dot, sparkgap/circle}{Spark gap (gas filled)}{}
\circuitdescbip*{loudspeaker}{loudspeaker}{}( north/90/0.4, ne/45/0.4, east/0/0.4, se/-45/0.4, south/-90/0.4, sw/-135/0.4, west/180/0.4, nw/135/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
\circuitdescbip*{mic}{mic}{}( north/90/0.4, east/0/0.4, south/-90/0.4, west/180/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
\circuitdescbip*{tlmic}{tail-less mic\footnotemark}{}( north/90/0.4, east/0/0.4, south/-90/0.4, west/180/0.4, left/135/0.2, right/45/0.2, center/-135/0.2)
Expand Down Expand Up @@ -3331,7 +3335,7 @@ \subsubsection{Miscellaneous element customization}\label{sec:tweak-misc}

You can change the scale of all the miscellaneous elements by setting the key \texttt{misc/scale} to something different from the default \texttt{1.0}; relative thickness can be controlled with \texttt{misc/thickness}.

\paragraph{Wiggly fuses} can have (or not have) poles; you can switch between the two forms by setting to \texttt{true} or \texttt{false} (default \texttt{true}) the key \texttt{bipoles/wfuse/dots}; if they have poles, you can choose any of the pole shapes with the key \texttt{bipoles/wfuse/shape}.
\paragraph{Wiggly fuses.} Wiggly fuses can have (or not have) poles; you can switch between the two forms by setting to \texttt{true} or \texttt{false} (default \texttt{true}) the key \texttt{bipoles/wfuse/dots}; if they have poles, you can choose any of the pole shapes with the key \texttt{bipoles/wfuse/shape}.
The pole nodes are named \texttt{-left} and \texttt{-right} so that you can access their borders.

\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
Expand All @@ -3347,14 +3351,30 @@ \subsubsection{Miscellaneous element customization}\label{sec:tweak-misc}
\end{circuitikz}
\end{LTXexample}

\paragraph{Neon lamps} ``dot'' size is the same as the size of poles (\texttt{circ} and \texttt{ocirc}), and they can be changed locally:
\paragraph{Neon lamps.} Neon lamp ``dot'' size is the same as the size of poles (\texttt{circ} and \texttt{ocirc}), and they can be changed locally:
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{tikzpicture}
\draw (0,0) to[neonlampcc, nodes width=0.03] ++(2,0)
to[neonlampac, misc/thickness=3] ++(2,0);
\end{tikzpicture}
\end{LTXexample}

\paragraph{Spark gap.} The \texttt{sparkgap} component is similar to the (American) surge arrester, but it's more configurable; it will render bare (unenclosed) by default, but you can add a (fillable) enclosure with the key \texttt{sparkgap/circle} and a dot with \texttt{sparkgap/dot} (they are boolean keys, false by default).
Moreover, the arrows are configurable like other arrows in the package (see~\ref{sec:tunablearrows}) using the \texttt{sparkgap end arrow} key (default \texttt{Triangle[scale=2]}). The gap is tunable with \texttt{sparkgap/gap} (default \texttt{0.05}).
\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily]
\begin{tikzpicture}
\draw (0,2) to[sparkgap, l=gap\textsubscript{1}] ++(2,0)
to[sparkgap, sparkgap/circle,
sparkgap/dot, l=S2] ++(2,0);
\ctikzset{sparkgap end arrow={Kite[scale=1.5]}}
\draw (0,0) to[sparkgap, l=S3] ++(2,0)
to[sparkgap, l=S4, sparkgap/circle,
sparkgap/gap=0.15] ++(2,0);
\end{tikzpicture}
\end{LTXexample}
As in neon lamps, the dot (if activated by the key \texttt{sparkgap/dot}) follows the size of poles and can be changed locally.


\subsection{Multiple wires (buses)}

These are simple drawings to indicate multiple wires.
Expand Down
45 changes: 44 additions & 1 deletion tex/pgfcircbipoles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7010,6 +7010,13 @@
% suggested by @bogger33, see https://github.com/circuitikz/circuitikz/issues/793
\ctikzset{bipoles/neonlampcc/height/.initial=.60}
\ctikzset{bipoles/neonlampac/height/.initial=.60}
\pgf@circ@declare@family@arrows{sparkgap}
\newif\ifpgf@sparkgap@dot
\newif\ifpgf@sparkgap@circle
\ctikzset{sparkgap/circle/.is if=pgf@sparkgap@circle}
\ctikzset{sparkgap/dot/.is if=pgf@sparkgap@dot}
\ctikzset{sparkgap/gap/.initial=.05}
\ctikzset{bipoles/sparkgap/height/.initial=.60}
%
\ctikzset{bipoles/squid/height/.initial=.60}
\ctikzset{bipoles/squid/width/.initial=.60}
Expand Down Expand Up @@ -7431,7 +7438,42 @@
\pgftransformshift{\pgfpoint{-\@@w\pgf@circ@res@right}{\@@h\pgf@circ@res@down}}
\pgfnode{circ}{center}{}{}{\pgfusepath{draw,fill}}
}

% spark gap, suggested by @bogger33 https://github.com/circuitikz/circuitikz/issues/800
\pgfcircdeclarebipolescaled{misc}
{
\savedmacro{\changeh}{\edef\changeh{\ifpgf@sparkgap@circle 1 \else 0.5 \fi}}
\pgfcirc@border@extend@updown{\changeh}{\changeh}
}
{\ctikzvalof{bipoles/sparkgap/height}}
{sparkgap}
{\ctikzvalof{bipoles/sparkgap/height}}
{\ctikzvalof{bipoles/sparkgap/height}}{
% circle (if requested)
\pgfscope
\ifpgf@sparkgap@circle
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@up}
\pgf@circ@draworfill
\fi
\endpgfscope
% arrows
\pgfscope
\pgfcirc@set@arrows{sparkgap}{}{Triangle[scale=2]}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
\pgfpathlineto{\pgfpoint{\ctikzvalof{sparkgap/gap}\pgf@circ@res@right}{0pt}}
\pgfusepath{draw}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{\ctikzvalof{sparkgap/gap}\pgf@circ@res@left}{0pt}}
\pgfusepath{draw}
\endpgfscope{}
% dot (if requested)
\ifpgf@sparkgap@dot
\pgftransformshift{\pgfpoint
{\ctikzvalof{sparkgap/gap}\pgf@circ@res@left-1*\ctikzvalof{nodes width}\pgf@circ@Rlen}
{-4*\ctikzvalof{nodes width}\pgf@circ@Rlen}}
\pgfnode{circ}{center}{}{}{\pgfusepath{draw,fill}}
\fi
}

%>>>

Expand All @@ -7440,6 +7482,7 @@
\pgfcirc@activate@bipole@simple{l}{lamp}
\pgfcirc@activate@bipole@simple{l}{neonlampcc}
\pgfcirc@activate@bipole@simple{l}{neonlampac}
\pgfcirc@activate@bipole@simple{l}{sparkgap}
\pgfcirc@activate@bipole@simple{l}{bulb}
\pgfcirc@activate@bipole@simple{l}{squid}
\pgfcirc@activate@bipole@simple{l}{barrier}
Expand Down

0 comments on commit 771c6c0

Please sign in to comment.