%^^A last update: Fri  03-13-1998
%\iffalse
%*******************************************************************
%***   Please run    tex circ.dtx  to install the CIRC package   ***
%***   or run      latex circ.dtx  to generate a documentation.  ***
%*******************************************************************
%<*installation>
% Hint: Comment the next line out to force installation under LaTeX.
%       \let\documentclass\relax
\expandafter\ifx\csname documentclass\endcsname\relax \input docstrip
\askforoverwritefalse\maxoutfiles{10} %<-- change this if you have problems
% CIRC is a LaTeX package to typeset circuit and optics diagrams.
% Copyright (C) 1997,1998,2003  Sebastian Tannert and Andreas Tille
%
%   This program is free software; you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation; either version 2 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this program; if not, write to the Free Software
%   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
%
% For error reports concerning UNCHANGED versions of this file no
% more than one year old, see CIRC.DVI after installation.
% If installation fails search thru this file for 'bug'.
%
%
\preamble
CIRC is a LaTeX package to typeset circuit and optics diagrams.
Copyright (C) 1997,1998,2003  Sebastian Tannert and Andreas Tille

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

For error reports concerning UNCHANGED versions of this file no
more than one year old, see CIRC.DVI after installation.
If installation fails search thru this file for 'bug'.
\endpreamble

 \keepsilent
  \generate{
     \file{circ.sty}    {\from{circ.dtx}{code}}
     \file{ic.def}      {\from{circ.dtx}{ic}}
     \file{gate.def}    {\from{circ.dtx}{gate}}
     \file{oldgate.def} {\from{circ.dtx}{oldgate}}
     \file{box.def}     {\from{circ.dtx}{box}}
     \file{basic.def}   {\from{circ.dtx}{basic}}
     \file{optics.def}  {\from{circ.dtx}{optics}}
     \file{physics.def} {\from{circ.dtx}{ciphysic}}
     \file{cisyms.tex}  {\from{circ.dtx}{doc}}
     \file{cidoc.tex}   {\from{circ.dtx}{docsty}}
     \file{circ.drv}    {\from{circ.dtx}{driver}}
  }
\postamble
\endpostamble
  \generate{
     \file{defcirc.mf}     {\from{circ.dtx}{defcircmf}}
     \file{csym.mf}     {\from{circ.dtx}{csym}}
     \file{cioptic.mf}   {\from{circ.dtx}{optic}}
     \file{ciphysic.mf} {\from{circ.dtx}{ciphysicmf}}
     \file{ciwidko.mf} {\from{circ.dtx}{csywidko}}
     \file{cidiod.mf}  {\from{circ.dtx}{csydiod}}
     \file{cirest.mf}  {\from{circ.dtx}{csyrest}}
     \file{cicirc.mf}  {\from{circ.dtx}{csycirc}}
     \file{cibimos.mf} {\from{circ.dtx}{csybimos}}
     \file{cisym.mf}   {\from{circ.dtx}{csysym}}
     \file{index.hlp}   {\from{circ.dtx}{indexhlp}}
   }
\message{*********************************************************************}
\message{^^JNow you should copy all *.def *.sty-files to your TEXINPUT-directory.}
\message{^^JPlease run "latex circ.drv" and read the section installation.}
\message{^^JAfter generating the fonts, please rerun "latex circ.drv".}
\message{^^JThen you will get a complete documentation.}
\message{^^JFor generating an index please read the file index.hlp.}
\message{*********************************************************************}
\csname fi\endcsname\end\endinput\fi
%</installation> end-metacomment \fi
% \def\filedate{2003/06/13}
%^^A last update: Fri  03-13-1998
% \def\fileversion{v1.0f}
% 
% \title{Package
%    \raise8mm\hbox{\expandafter\ifx\csname circfonts\endcsname\relax\else
%    \circuit2 \CIRCLogo \endcircuit\fi}\\[5mm]
%    \fileversion\ last revised \filedate}
% {
% \def\thefootnote{\fnsymbol{footnote}}
% \author{Sebastian Tannert\footnote{macro code}\\
%         Andreas Tille\footnote{documentation, optics}}}%
% \parskip 1mm\parindent0pt
% 
% \font\manual=logo10
% \def\MF{{\manual METAFONT}\xspace}
% \def\MP{{\manual METAPOST}\xspace}
% \def\META{{\manual META}\xspace}
% \def\CIRC{{\sf CIRC}\xspace}
% \def\CB#1{{\tt\char'134 #1}\index{#1@\string\texttt{\string\char'134 #1}}}
% \def\warp#1{{\tt\char'134 #1}}
% \def\Blank{{\tt\char32}}
% \def\einruck{\hspace*{1cm}}
% \def\example#1{\par\medskip\einruck#1\par\medskip}
% \def\kohm{$\,$k$\Omega$}
% \newcommand{\Descriptionlabel}[1]{\mbox{\textsf{#1}}\hfil}
% \newenvironment{Description}[1]%
%  {\begin{list}{}%
%         {\renewcommand{\makelabel}{\Descriptionlabel}%
%          \setlength{\parsep}{0pt}%
%          \setlength{\itemsep}{0pt}%
%          \setlength{\itemindent}{0pt}%
%          \setlength{\topsep}{0pt}%
%          \setbox0=\hbox{\Descriptionlabel{#1}}%
%          \setlength{\labelwidth}{\wd0}%
%          \dimen0=\labelwidth\advance\dimen0 by \labelsep%
%          \setlength{\leftmargin}{\dimen0}}}%
%  {\end{list}}
%
% \batchmode
% \iffalse First we have to check the fonts. \fi
% \font\checkcircfonts=cirest
% \dimen0=\fontdimen6\checkcircfonts
% \ifdim\dimen0>0pt \def\circfonts{exist}\fi
% \errorstopmode
% \maketitle
%
% \begin{abstract}
% \noindent
% The package \CIRC is a tool for typesetting circuit diagrams
% and block schematics.
% It defines several electrical symbols such as resistors, capacitors,
% transistors etc. These symbols can be connected with wires in a
% very easy way.
%
% To use \CIRC you only need \MF and \LaTeXe{}. You do not need
% PostScript or any drawing tool. You can expand \CIRC easily with
% your own symbols, written in \MF.
% \end{abstract}
%
% \vskip 15mm
% \expandafter\ifx\csname circfonts\endcsname\relax\else
%\begin{circuit}{0}
%\.1 \- 1 r \nl\cc\R1 {R} r
%\frompin .1 \- 3 l \- 2 d \nl\R9 {2R} d
%\- 10 d \.7
%\frompin .7 \- 3 l \cc\U0 {} - u
%\frompin .1 \- 2 d \nl\cc\R2 {2\,R} d \nl\SW1 {} s U
%\frompin SW1c \vtopin U0+ \.8
%\frompin SW1o \vtopin U0- \.9
%\frompin R1r \- 1 r
%\.3 \- 1 r \nl\cc\R5 {R} r
%\frompin .3 \- 2 d \nl\cc\R6 {2\,R} d \nl\SW3 {} s u
%\frompin SW3c \vtopin U0- \.12
%\frompin SW3o \vtopin U0+ \.13
%\frompin R5r \- 1 r
%\.4 \- 2 r \nl\cc\R7 {R$_1$= 2R} r
%\frompin .4 \- 2 d \nl\cc\R8 {2\,R} d \nl\SW4 {} s U
%\frompin SW4c \vtopin U0+ \htopin U0+
%\frompin SW4o \vtopin U0- \.15
%\frompin R7r \- 1 r \nl\whatI1 {I} s r
%\- 1 r \.5 \- 1 r \nl\OV1 {} - {} {} {}
%\frompin .5 \- 3 u \centerto OV1 \nl\cc\R10 {R$_2$} r
%\frompin R10l \htopin .5
%\atpin OV1O \.6 \vtopin R10r \htopin R10r
%\frompin .6 \- 1 r \connection1 {$U_a$} c r
%\frompin OV1+ \- 1 l \- 3 d \nl\cc\R11 {R$_3$} d
%\frompin R11b \vtopin .7 \.8 \GND1 \frompin .7 \htopin .8
%\end{circuit}\fi
% \clearpage
% \tableofcontents
% \enlargethispage{.5cm}
% \section{Introduction}
%
% In several sciences circuit diagrams are necessary in publications.
% Perhaps there are some PostScript tools for typesetting them or
% a drawing program has to be used.
% With \CIRC it is now possible to typeset circuit diagrams using
% \TeX\ commands. The commands
% describe the logical structure of the wiring scheme and \TeX\
% builds the connections according to this structure.
%
% \CIRC defines several electrical symbols such as resistors, capacitors,
% transistors etc. These symbols can be connected with wires in a
% very easy way.
%
% To use \CIRC you only need \MF and \LaTeXe{}. You do not need
% PostScript or any drawing tool. You can expand \CIRC with
% your own symbols, written in \MF.
%
% \CIRC has been implemented as a turtle system. That means, there is
% a current position from where the symbols and wires are drawn.
% It is possible to choose the drawing direction and drawing position.
%
% \CIRC consists of commands in order to
% \begin{Description}{position}
%  \item[draw] symbols and wires into the scheme,
%  \item[justify] symbols within the scheme,
%  \item[link] symbols with wires,
%  \item[position] symbols absolutely or relatively.
% \end{Description}
%
% \section{Installation}
%
% Run |circ.ins| through \LaTeX. You will get a couple of
% |*.mf| files. Use \MF to create |*.pk| fonts from all these files.
% These steps depend on your installation.
% For example, type:
% \begin{verbatim}
%    mf \mode=localfont; input ciwidko.mf
%    gftopk ciwidko.300
% \end{verbatim}
% Do this with all the |*.mf| sources. Copy the resulting |*.tfm|
% and |*.pk| files into appropriate directories.
%
% Copy the |*.sty|, |*.def| files, obtained from |circ.ins| into appropriate
% directories in your |TEXINPUT| path.
%
% Read the documentation carefully.
%
% Enjoy \CIRC.
%
% We added a Makefile which is tested only under |Debian\GNU Linux|
% (running |teTeX|).  We would like to get comments whether it works
% under other environments.  {\bf Use it at your own risk!}.  Type
% \begin{verbatim}
%    make
% \end{verbatim}
% to get all files used by \CIRC.  Before you type 
% \begin{verbatim}
%    make install
% \end{verbatim}
% you should check the correct PATH names in the Makefile.  (Make sure
% you run |make install| as root.)  This will do the the following:
% \begin{enumerate}
%   \item Delete old \CIRC files in |TEXINPUT| and |MFINPUT|.
%   \item Move the new |TEXINPUT| and |MFINPUT| to the appropriate
%         directories
%   \item Check the special.map file in the |Fontname| directory
%         whether there ary \CIRC related entries and create them
%         if failed.  (This will ensure that \CIRC fonts will be
%         copied into reasonable directories when using |MakeTeXPK|
%         or |MakeTeXTFM|.)
%   \item Delete old PK and TFM files from \CIRC.  (Using old TFM or
%         PK files is one of the "Top ten reasons" why failing \CIRC.)
% \end{enumerate}
% To get the documentation type
% \begin{verbatim}
%    make doc
% \end{verbatim}
% (generally this is a good idea to create the needed fonts on the
% fly).
%
% Once more: Please report any bug concerning this Makefile, because
% this is the first test and not reliable at all.
%
%
% \section{System requirements}
%
% \CIRC requires \LaTeXe\ and \MF.
%
%\section{Changes}
% Unfortunately a change of the parameters for symbol drawing
% commands had to be made. But now the rules are more consistent and
% easier to remember. Please have a look at section~\ref{pars}.
% Some new symbols were added and the font selection was modified
% to work together with the slides class.
% The appendix has a new design to be clearly arranged.
% Font names have changed too.
%
% The |\<| command is obsolete now and should NOT used anymore.
% A new |\_| command was defined, see section~\ref{position}.
%
% \section{Usage}
%
% \subsection{Preambel}
%
% \CIRC is divided into several parts. To use a part put the suitable
% option in the |\usepackage| command. All parts are included
% in the following example:
%\example{\warp{usepackage[basic,box,gate,oldgate,ic,optics,physics]}\{|circ|\}}
%
% The parts contain:
% \begin{Description}{physics\,:}
% \item[basic\,:]  a lot of symbols such as resistors, capacitors, switches,
%                  diodes, transistors, etc.,
% \item[box\,:]    blackbox, oscilloscope, generator and amplifier,
% \item[gate\,:]   several logical circuits,
% \item[oldgate\,:] old style logical gates,
% \item[ic\,:]     integrated circuits (flip flops, etc.) and
% \item[optics\,:] the optical stuff with lenses, mirrors, etc.
%                  (see section \ref{optic}),
% \item[physics\,:] some mechanics stuff.
% \end{Description}
% A complete list of available symbols is given in the appendix.
%
% \subsection{Starting a circuit diagram}
%
% It is recommended to draw a sketch with pen and paper before using
% \CIRC.
%
% Every circuit diagram is enclosed in the
% |circuit| environment
% \example{\CB{begin\{circuit\}}{\em size}}
% where {\em size} is an integer
% between 0 and 4 giving the size of symbols and describing text. A size
% of 4 is useful for overhead foils.
%
% All \CIRC macros and the necessary parameters are separated by
% spaces (\Blank). For a clearly arranged \CIRC diagram it is
% advisable to put every command in a separate line (a linebreak
% is interpreted as a blank as it is used in \TeX).
%
% \subsection{Drawing symbols}
% \label{pars}
% The table in the appendix contains a complete list of all 
% \CIRC symbols available and corresponding drawing commands.
% The syntax of drawing commands is:
% \example{\warp{}{\sf symbolname}{\em number\Blank
%  inscription\Blank{\tt[}specification\_parameter{\tt]}\Blank direction}}
% or for more complex symbols:
% \example{\warp{}{\sf symbolname}{\em number\Blank {\tt[}further\_parameters\tt ]}}
% Note that you can leave out the blank between the symbol-command
% and the following {\em number} parameter. This parameter has to
% be unique in one drawing and is necessary for correct referring
% (see |\atpin| in section \ref{poscmd}).
%
% The symbols can be classified into a lot of different symmetries
% which are summarized in the appendix. There you will find more
% detailed information about the parameters you have to use.
% Generally the drawing direction of the symbol is given with the
% {\em direction} parameter which is |l| (left), |r| (right),
% |u| (up) or |d| (down).
% If there exist 2 different alignments of a symbol for one
% direction (e.g. if the LED-arrows show up or down) the second
% alignment is chosen by capitalization of the {\em direction}
% parameter (|L|, |R|, |U| or |D|).
%
%\iffalse
% Due to the fact, that there are different symbols for different
% drawing directions the right {\em direction} parameter is important.
% The table in the appendix contains valid {\em direction} parameters
% for every drawing command. This may be |h| (horizontal) or |v|
% (vertical) for symbols with the symmetry two; |l| (left), |r| (right),
% |u| (up) and |d| (down) for symbols with the symmetry four or
% for symbols with the symmetry eight |l|, |L|, |r|, |R|, |u|, |U|,
% |d| or |D|. The latter may need further {\em specification} parameter
% in front of the {\em direction} parameter.
% \fi
% Symbols having two dissimilar or more connections may need
% a further {\em specification} parameter in front of the {\em
% direction} parameter.
% This {\em specification} parameter marks the pin
% that should be on the current drawing position (see variable resistor and
% several transistors).
%
% In the appendix {\tt text} was used for the {\em inscription} and the
% necessary {\em number} was set to {\tt n}. Note the position
% at the symbol where the inscription is set.
% The inscription can be suppressed by the \CB{nv} command in front
% of the symbol-command.
%
% By default every \CIRC symbol is marked by a label.
% This label consists of an abbreviation of the symbol indexed by
% the {\em number}. To suppress
% this labeling use \CB{nl} in front of the symbol-command.
%
% Another command affecting the inscription of a symbol is
% \CB{cc}. It is also used in front of a symbol-command and causes the
% change of label-position and inscription-position. By default the
% inscription is typeset left or over the symbol while the labeling
% is done right or under the symbol depending on the vertical or
% horizontal orientation of the symbol.
%
% Some symbols need {\em further\_parameter}s. The usage
% is selfdocumenting in the appendix table.
%
% Junctions can be made by the \CB{.} command
% (\CB{junction})\footnote{Commands within
% parenthesis are synonyms for the last introduced command.}.
% The syntax is:
% \example{\warp{.}{\em number}}
% Every junction needs a {\em number} argument for further referencing.
%
% \subsection{Referencing symbols and pins}
%
% Some commands use reference parameters
% to mark symbols or connections of symbols drawn before.
%
% The {\em symbol\_reference} parameters consist of two parts:
% \example{{\sf symbolname}$\;${\em number}}
%
% The {\em pin\_reference} parameters consist of three parts:
% \example{{\sf symbolname}$\;${\em number}$\;${\sf pinname}}
% These three parts form the {\em reference} parameter.
%
% See the appendix for the pinnames, they are drawn nearby the pins.
% If the symbol has no pregiven ones the standard names |l| for
% the left connection, |r| for the right, |t| for the top and
% |b| for the bottom one will be chosen.
%
% {\em Note that there is no blank between the parts!}
%
% For example, to refer to the \underline{l}eft connection of the
% resistor with the {\em number} 1 the {\em pin\_reference} parameter
% would be
% \example{{\tt R1l}}
% or to refer to the whole symbol the {\em symbol\_reference} is
% \example{{\tt R1}\quad.}
%
%
% At least it is possible to set markers which work like pin references.
% \example{\CB{P}{\em number}}
% sets a marker which can be referred to by |P|{\em number}.
%
% \subsection{Connecting symbols}
%
% Simple connections between the symbols can be made with the
% \CB{-} command, which is an abbreviation of the \CB{wire}
% command (see appendix). The syntax is
% \example{\warp{-}\Blank{\em length}\Blank{\em direction}.}
% The parameter {\em length} is an integer giving the number of
% lengthsteps. In \CIRC wires are build as a queue of characters
% 2.5\,mm each. Thus the length of wire is measured in multiples
% of this length.
%
% The parameter {\em direction} determines the direction. Valid
% values are |l| for left, |r| for right, |u| for up and |d| for
% down. For instance, a wire is drawn to the left with a length of
% 1\,cm (4 units) by typing
% \example{\warp{-\Blank 4\Blank l}}
%
% There are some other line types to connect symbols. The command
% \example{\CB{dashed}\Blank{\em length\Blank direction}}
% draws a dashed line. It is written as the \warp{-} command.
% With
% \example{\CB{bundle}\Blank{\em text\Blank length\Blank direction} \\
%          \einruck\CB{wwire}\Blank{\em text\Blank length\Blank direction}}
% a bundle of wire could be drawn or a pair of wire, respectively.
% You can use \CB{=} as an abbreviation of |\wwire|.
% The {\em text} may contain any comments.
%
% To connect the drawing position horizontally or vertically with
% a certain pin of a symbol by using a reference, the useful
% commands \CB{htopin} and \CB{vtopin} exist.
% The syntax is:
% \example{\warp{htopin}\Blank{\em pin\_reference} \\
%          \einruck\warp{vtopin}\Blank{\em pin\_reference}}
% Provided that the resistor |R1| defined before by a |\R| command,
% the command
% \example{\warp{vtopin\Blank R1l}}
% draws a vertical wire up to this height, where the resistor numbered
% with |1| (|R1|) is situated. |\htopin| does the same but horizontally.
%
% The connection will be done by default with the \CB{wire} command.
% To change the type of the connection use the \CB{by} command.
% The syntax is:
% \example{\warp{by\{}{\em command\/}|\}|}
% where {\em command} can be one of the following: \CB{wire} (\CB{-}), \CB{dashed},
% \mbox{\CB{bundle}\Blank{\em text}}, \mbox{\CB{wwire}\Blank{\em text}}
% or \CB{oa} (which is declared in the optics part, see section \ref{optic}).
%
% For example, the command
% \example{\warp{by\{}\warp{dashed\}}}
% changes the drawing style from \warp{[hv]topin} to a dashed lines.
% Do not forget to switch back to wires using
% \example{\warp{by\{}\warp{wire\}}}
% to end the dashed lines.
%
% Note that it is usually necessary to combine the |htopin|- and
% |vtopin| commands, because these commands draw {\em only} horizontally
% or vertically to the x- or the y-coordinates
% of the given pin.
%
% \subsection{\label{poscmd}Positioning commands}
% \label{position}
% Positioning commands are used to change the current
% drawing position.
%
% The direct positioning command \CB{at} (\CB{from}) sets the drawing position
% to an absolute coordinate.
% \example{\warp{at\{{\em x}\}\Blank\{{\em y}\}\Blank}}
% sets the drawing position to the point ({\em x},{\em y}) in the coordinate
% system, where {\em x} and {\em y} are integers counting the number of
% arbitrary units (2.5\,mm). \CIRC starts drawing at $(0,0)$.
%
% It is recommended to avoid the absolute positioning of symbols, because
% it tends to destroy the logical structure of the circuit diagram.
%
% The drawing position can be changed in relation to the current position
% with the indirect positioning command \CB{moverel} (\CB{shift}).
% \example{\warp{moverel\{{\em x}\}\Blank\{{\em y}\}\Blank}}
% moves the drawing position {\em x} units to the right
% and {\em y} units upwards.
%
% The command \CB{atpin} (\CB{frompin}) sets the drawing
% position to a reference pin.
% \example{\warp{atpin}\Blank{\em pin\_reference}}
% allows further drawing starting from the reference pin. For example,
% \example{\warp{atpin C2r}}
% sets the drawing position to the right pin of the capacitor numbered 2.
%
% In a lot of cases a command like |\-| is useful, but it should
% not draw the line. |\_| satisfy this need. As you know from
% |\-| a {\em length} and a {\em direction} must be specified.
%
% \subsection{Justify commands}
%
% The command \CB{hcenterto} forces horizontal centering
% according to a symbol referred to. The command \CB{vcenterto} does the
% same but vertically.
% The command \CB{centerto} centers the following symbol according to the
% reference symbol
% horizontally or vertically depending on the drawing direction of
% the symbol beeing drawn.
%
% The syntax is:
% \example{\warp{hcenterto}\Blank{\em symbol\_reference} \\
%          \einruck\warp{vcenterto}\Blank{\em symbol\_reference} \\
%          \einruck\warp{centerto}\Blank{\em symbol\_reference}}
% For example,
% \example{\warp{hcenterto L4}}
% would force horizontal centering according to the coil numbered 4.
% 
% \subsection{Text commands}
%
% The command
% \example{\CB{put}|\{|{\em text}|\}|}
% puts {\em text} at the current drawing position.
% It can be used in the same way as the \warp{put} command of the
% \LaTeX |picture| environment, but the coordinates have to be omitted
% (because they are given by the current drawing position).
%
% To comment something the commands
% \example{\CB{Utext}\Blank{\em text\Blank{\tt from}\Blank pin\_reference1\Blank{\tt to}\Blank pin\_reference2} \\
%  \einruck\CB{centertext}\Blank{\em text\Blank{\tt from}\Blank pin\_reference1\Blank{\tt to}\Blank pin\_reference2}}
% can be used. \warp{centertext} prints {\em text} centered between
% {\em pin\_reference1} and {\em pin\_reference2}.
% \warp{Utext} additionally draws an arrow from
% {\em pin\_reference1} to {\em pin\_reference2}.
% Note that the reference pins must have the same x- or y-coordinate.
%
% To write overlapping information like the \TeX\ commands
% \warp{rlap} and \warp{llap} the following commands are used:
% \example{\CB{blap}|\{|{\em text}|\}| \\
%          \einruck\CB{tlap}|\{|{\em text}|\}|}
% They put {\em text} which overlap to the bottom or the top, respectively.
%
% \expandafter\ifx\csname circfonts\endcsname\relax
% \LARGE Please generate the fonts now. Then you will get a
% complete documentation.\stop\fi
%
% \subsection{Example}
%
%A simple example is the diagram showing a circuit which is used for measuring
%the amplification of current by a transistor.
%\vskip 4mm
%\begin{circuit}0
%\npn1 {?} B l
%\frompin npn1C
%\- 1 u
%\nl\A1 {$I_C$} u
%\atpin npn1B
%\- 1 l
%\R1 {510\kohm} l
%\- 1 l
%\centerto A1
%\nl\A2 {$I_B$} u
%\frompin A2b
%\vtopin R1l
%\frompin A1t
%\- 1 u \.1
%\frompin A2t
%\vtopin .1
%\htopin .1
%\- 1 u
%\cc\connection1 {$U_b$} c u
%\frompin npn1E
%\- 1 d
%\GND1
%\end{circuit}
%\vskip 4mm
%
%How to cope with such sketches?
%
%First of all, it is necessary to decide, which symbol should be the
%first one.
%The transistor seems to be a good choice to begin with in this
%special case. The command \CB{npn} produces a npn-transistor
%(see appendix); so the first line is
%\example{\warp{npn1 {?} B l}}
%which names the transistor |npn1| for further reference.
%Instead of |{?}| any text describing the specific transistor
%may be written. (Unfortunately this doesn't work today. See
%future plans.) The third parameter |B| means, that the
%\underline{b}ase of the transistor should be on the current
%drawing position. Further more |C| for \underline{c}ollector
%or |E| for the \underline{e}mitter contact would be possible.
%The last parameter gives the direction, in this case the
%base contact points to the \underline{l}eft (|l|).
%
%Use
%\example{\warp{frompin npn1C}}
%to continue drawing from the collector, and type
%\example{\warp{- 1 u}}
%to draw the needed wire \underline{u}pwards
%to connect the amperemeter to measure $I_C$ which is created by the command
%\example{\warp{nl}\warp{A1 \{\$I\_C\$\} u}}\qquad .
%
%The command \CB{nl} in front of the amperemeter avoids the default
%inscription of "$I_1$" because this would not make any sense in this
%case. Instead, the labeling is $I_C$. The last parameter {\tt u}
%marks the direction (\underline{u}p).
%
%To draw the resistor connected with the base of the transistor
%the proceeding is the same: use
%
%|\atpin npn1B |
%to set drawing position (different from the current position),
%
%|\- 1 l |
%to draw a piece of wire to the left and
%
%|\R1 {510\kohm} l |
%for the resistor itself.
%
%A further horizontal piece of wire connects the resistor with the
%second amperemeter: |\- 1 l |.
%
%The second amperemeter, measuring the current of the base ($I_B$),
%would look nice at if drawn the same height as the first one,
%measuring ($I_C$).
%Measuring the length of wire needed to match the same height would be
%difficult and a change of the diagram would cause further changes in
%order to maintain the desired position.
%Therefore it is advisable to use
%\example{\CB{centerto} {\tt A1}\quad \warp{nl}\warp{A2 \{\$I\_B\$\} u}}
%which leeds to the intended centering automatically. Because of the
%\underline{u}p orientation of {\tt A2}, the centering is the same as
%in the vertical direction.
%
%A vertical connection is needed to connect the amperemeter
%with {$R_1$}. This may be done by
%\example{\warp{frompin A2b} \\
%         \einruck\warp{vtopin R1l}}
%which draw a wire down to the horizontal wire, starting at
%|A2b|. Instead of the second line |\vtopin npn1B| would do the same job
%because the horizontal position is irrelevant for \CB{vtopin}.
%
%To connect the two amperemeters the drawing position is set to |A1t|,
%from where a wire is drawn upwards and a junction point is marked
%at that point by using
%\example{\warp{frompin A1t} \\
%         \einruck\warp{- 1 u} \\
%         \einruck\warp{.1}}
%The commands for connecting the second amperemeter are:
%\example{\warp{frompin A2t} \\
%         \einruck\warp{vtopin .1} \\
%         \einruck\warp{htopin .1}}
%The combination of \CB{htopin} and \CB{vtopin} is very useful
%to connect two points with an edge of wire.
%The driving voltage is typeset by
%\example{\warp{- 1 u} \\
%         \einruck\warp{cc}\warp{connection1 \{\$U\_b\$\} c u}}
%because it looks better to put the inscription of the voltage on the
%right. That is why the prefix \CB{cc} is used in front of
%the \warp{connection} command.
%
%Finally the emitter contact leads to the ground:
%\example{\warp{frompin npn1E} \\
%         \einruck\warp{- 1 d} \\
%         \einruck\warp{GND1}}
%
%The whole example once more in an overview:
%\begin{verbatim}
%\begin{circuit}0
%\npn1 {?} B l              % transistor
%\frompin npn1C             % draw from collector
%\- 1 u                     % some wire
%\nl\A1 {$I_C$} u           % amperemeter for current of collector
%\atpin npn1B               % continue drawing from base
%\- 1 l                     % some wire
%\R1 {510\kohm} l           % resistor
%\- 1 l                     % some wire to the edge
%\centerto A1               % draw centered to amperemeter 1
%\nl\A2 {$I_B$} u           % amperemeter 2
%\frompin A2b               % link amperemeter 2 with resistor
%\vtopin R1l
%\frompin A1t
%\- 1 u
%\.1                        % junction
%\frompin A2t               % wire to amperemeter 2
%\vtopin .1
%\htopin .1
%\- 1 u
%\cc\connection1 {$U_b$} c u  % driving voltage
%\frompin npn1E
%\- 1 d
%\GND1                      % ground
%\end{circuit}
%\end{verbatim}
%
%
% \section{\label{optic}Optics}
%
% If the |optics| option is given in the |\usepackage| command, the
% creation of simple optical diagrams is possible.
%
% The optical axis can be drawn with the \CB{oa} command, which
% creates a dashed line.
% The optical symbols
% which are available are listed at the end of the appendix.
% 
% Here is an example for using |optics|. With the knowledge
% of drawing circuits the following code will speak for itself.
% \vskip 4mm
%    \begin{circuit}{0}
%       \nl\Laser1 {} r                    
%       \oa 2 r                            
%       \Polar1 {} r                       
%       \oa 2 r				   
%       \nl\OM1 P1 {} {} {} {} h           
%       \atpin OM1P3			   
%       \oa 4 r				   
%       \cc\BLens1 {} r                    
%       \oa 2 r				   
%       \nl\Pinhole1 {} r                  
%       \oa 7 r				   
%       \cc\SLens2 {} r                    
%       \oa 1 r     			   
%       \Polar2 {} r                       
%       \oa 3 r				   
%       \oa 3 r				   
%       \nl\BSplit1 {} + d                 
%       \atpin BSplit1+                    
%       \oa 2 r				   
%       \nl\Cam1 {camera} . r              
%       \atpin BLens1: \shift 0 2 \P3      
%       \atpin Pinhole1: \shift 0 2 \P4    
%       \atpin SLens2: \shift 0 2 \P5      
%       \Dtext{\small $f_1$} from P3 to P4 
%       \Dtext{\small $f_2$} from P4 to P5 
%       \atpin BSplit1.                    
%       \oa 5 d				   
%       \Mirror1 {} * R                    
%       \oa 2 r				   
%       \nl\ScrL1 {screen} h               
%    \end{circuit}
% Here is the code:
% 
% \begin{verbatim}
%    \begin{circuit}{0}
%       \nl\Laser1 {} r                    % laser
%       \oa 2 r                            % optical axis
%       \Polar1 {} r                       % polarizer
%       \oa 2 r
%       \nl\OM1 P1 {} {} {} {} h           % optical modulator
%       \atpin OM1P3
%       \oa 4 r
%       \cc\BLens1 {} r                    % 1st lens
%       \oa 2 r
%       \nl\Pinhole1 {} r                  % pinhole
%       \oa 7 r
%       \cc\SLens2 {} r                    % 2nd lens
%       \oa 1 r     
%       \Polar2 {} r                       % analyzer
%       \oa 3 r
%       \oa 3 r
%       \nl\BSplit1 {} + d                 % beam splitter
%       \atpin BSplit1+                    % continue drawing right
%       \oa 2 r
%       \nl\Cam1 {camera} . r              % camera
%       \atpin BLens1: \shift 0 2 \P3      % mark middle of 1st lens
%       \atpin Pinhole1: \shift 0 2 \P4    % mark middle of pinhole
%       \atpin SLens2: \shift 0 2 \P5      % mark middle of 2nd lens
%       \Dtext{\small $f_1$} from P3 to P4 % f_1
%       \Dtext{\small $f_2$} from P4 to P5 % f_2
%       \atpin BSplit1.                    % second part of beam down
%       \oa 5 d
%       \Mirror1 {} * R                    % mirror
%       \oa 2 r
%       \nl\ScrL1 {screen} h               % white screen
%    \end{circuit}
% \end{verbatim}
%
%
% \section{Some hints for \CIRC programmers}
%
% Here are some hints to add further symbols to \CIRC.
%
% Before creating any new symbol consult very carefully the file |csym.mf|.
% It contains a lot of very useful definitions to simplify writing new symbols.
% Examples for the use of these definitions are given in the files
% |ciwidko.mf| and |optic.mf|.
% When possible it is strongly recommended to use the \MF commands
% \begin{Description}{|fourfourchars|}
% \item[|twochars|] for symbols with the symmetry two,
% \item[|fourchars|] for symmetry four and
% \item[|fourfourchars|] for symmetry eight,
% \end{Description}
% because the definition of the corresponding \TeX\ command
% will need only one line! If there are any problems with \MF{}
% do not hesitate to contact the authors.
%
% A new option file with the extension |def|,
% for instance |newcirc.def|, has to be created to include
% the written symbols. To include the new definitions add
% |newcirc| to the options in the \warp{usepackage} command:
% \example{\warp{usepackage[basic,newcirc]\{circ\}}\qquad .}
%
% The \CIRC-command \CB{freecirc} has to be used to start the
% definitions of new commands in the file |newcirc.def|.
% This ensures, that the asterix (`*') becomes active, because
% all internal \CIRC commands contain the asterix. It is comparable to
% \LaTeX 's \warp{makeatletter}. The \CIRC-command \CB{protectcirc}
% has to be used at the end of the file |newcirc.def|
% in order to restore the former
% behaviour (comparable to \warp{makeatother}).
%
% The \CB{cdef*} commands are strongly recommended to declare commands
% with the new symbols, because only one line is needed for the definition.
% The files |basic.def| or |optics.def| contain examples for \warp{cdef} and
% related commands, which are defined in |circ.sty|.
%
% To ensure that the new symbols are inserted in the right
% magnification the command \CB{extracircinit} may be used.
% It can be used in the same way as \warp{opticfontinit} is used
% in |optics.def|. Both are defined in |circ.sty| as \warp{relax}
% and are called when a new diagram is initialized. If it is necessary
% to do any operations before starting a circuit diagram, then
% it is possible to redefine \warp{extracircinit} to do the job.
%
% \section{Future plans}
% \CIRC is still under development. A lot of users need
% additional symbols or have other wishes. In most of the cases there is
% a quick solution, but to give \CIRC the ability to be an easy
% extendable tool (and to add more potentiality) it has to be rewritten.
% Until this is done there could happen the following steps:
%\begin{itemize}
%\item solve the problem of inscriptions for transistors
%\item redesign some symbols and reimplement the \MF sources
%\item rewrite the font selection to fix some ugly effects
%\item add color support and build a \MP port
%\item use the NFSS2 to make different linethicknesses available
%\item describe the link between \TeX\ and \META
%\item update the documentation every time
%\end{itemize}
%
%
% \section{Contacting the authors}
% Any bug reports, remarks, proposals for new options and symbols,
% any improvements to both the code or the documentation
% as well as some nice postcards are welcome.
%
% \medskip
% \begin{tabular}{@{}p{.5\hsize}@{}p{.5\hsize}@{}}
% Sebastian Tannert                  & Andreas Tille                 \\
% WEN 67.02.01.06                    & Gartenstra\ss e 8             \\
% Harbigstra\ss e 14                 & D-38855 Wernigerode           \\
% D-14055 Berlin                     &                               \\
% &\\
% tannert@physik.hu-berlin.de        & tille@physik.uni-halle.de
% \end{tabular}
% \iffalse Some changes to the layout for the appendix. \fi
%\advance\textheight\topmargin
%\advance\textheight60pt
%\advance\textheight\headsep
%\advance\textheight\headheight
%\newpage
%\topmargin-30pt
%\headsep0pt
%\headheight0pt
%\oddsidemargin10pt
%\parindent 0pt
%\lineskip4mm
%^^A last update: Fri  03-13-1998
% \section{\appendixname}
%\def\spc{\,\texttt{\char'40}\,}
%\def\num{\textit{number}}
%\def\len{\textit{length}}
%\def\dir{\textit{direction}}
%\def\txt{\textit{text}}
%\def\lab#1{\textit{label} \textrm{#1}\spc}
% The symmetries and there parameters:\\[1mm]
% \catcode`\|=12
% \begin{tabular}{l|l}
% symmetrie & parameter set \\[1mm]\hline
% $\mathcal{OP}$ & \num\spc\\[1mm]
% $\mathcal{LI}$ & \len\spc\dir\spc\\[1mm]
% $\mathcal{LB}$ & \num\spc\txt\spc\dir\spc\\[1mm]
% $\mathcal{TXT}$ & \txt\spc\texttt{from}\spc
% \textit{pin\_reference1}\spc\texttt{to}\spc\textit{pin\_reference2}\spc\\[1mm]
% $\mathcal{SO}$ & \num\spc\txt\spc\dir[l,r,u,d]\spc\\[1mm]
% $\mathcal{SX}$ & \num\spc\txt\spc\dir[l,r,u,d,L,R,U,D]\spc\\[1mm]
% $\mathcal{SXY}$ & \num\spc\txt\spc\dir[l,r,u,d]\spc\\[1mm]
% $\mathcal{S\mathrm{3}P}$ & \num\spc\txt\spc\textit{pin\_name}\spc\dir[l,r,u,d,L,R,U,D]\spc\\[1mm]
% $\mathcal{GI}$ & \num\spc\txt\spc\textit{pin\_name}\spc\lab a\lab b\\[1mm]
% $\mathcal{GII}$ & \num\spc\txt\spc\textit{pin\_name}\spc\lab a\lab b\lab c\\[1mm]
% $\mathcal{BX}$ & \num\spc\textit{pin\_name}\spc\lab a\lab b\lab c\lab d\\[1mm]
% $\mathcal{BXT}$ & \num\spc\txt\spc\textit{pin\_name}\spc\lab a\lab b\lab c\lab d\\[1mm]
% $\mathcal{IC}$ & \num\spc\txt\spc\textit{pin\_name}\spc\textit{style\footnote{Today this should be empty, like \{\}.}}\spc\\[1mm]
% \end{tabular}\vskip 10mm
% \MakePercentComment\input{cisyms}\MakePercentIgnore
% \advance\hsize-4cm
% \oddsidemargin35pt
% \newpage
% \PrintIndex
% \iffalse DON'T process driver definitions!
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\begin{filecontents}{circ.ist}
delim_0 "\\hfill "
delim_t "\\hbox to 7mm{\\hss}"
\end{filecontents}
\documentclass{ltxdoc}
\usepackage[basic,box,gate,oldgate,ic,optics,physics]{circ}
\usepackage{t1enc}
\usepackage{xspace}
\IndexPrologue{\section{Index}}
\makeindex
\begin{document}
\DocInput{circ.dtx}
\end{document}
%</driver>
% \fi
%^^A last update: Fri  03-13-1998
%\iffalse
%<*docsty>
%\fi
\chardef\backslash="5C
\catcode`\|=12
\parindent 2mm
\lineskip 0pt
\advance\textwidth by 39.4pt

\def\lpin#1{\shift -1.1 0 \put{\tlap{\llap{\tt#1$\rfloor$}\vss}}}
\def\bpin#1{\shift 0 -1.5 \put{\blap{\llap{\tt#1\hss}}}}
\def\tpin#1{\shift 0 1.5 \put{\tlap{\llap{\tt#1\hss}}}}
\def\rpin#1{\shift 1.1 0 \put{\tlap{\rlap{$\lfloor$\tt#1}\vss}}}

\def\cdef#1 #2 #3#4 #5 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} r \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{SXY}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cwdef#1 #2 #3 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #3\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname 6 r \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{LI}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}



\def\cwwdef#1 #2 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #2\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname {text} 6 r \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{LB}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\NgateIIO#1 #2#3 #4 #5 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} : a b c 
   \atpin{#1nI1} \lpin{I1}  \atpin{#1nI2} \lpin{I2} \atpin{#1nO} \rpin{O}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{GII}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\gateIIO#1 #2#3 #4#5 #6 #7 #8 {\noindent
\hbox{\vbox to 3.8cm{\vskip 2mm
 {\hsize 4.8cm \footnotesize #8\par}
 \vfill
 \hbox to 5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} : a b c
   \atpin{#1n#5} \lpin{#5}  \atpin{#1n#7} \lpin{#7} \atpin{#1n#6} \rpin{#6}
   \end{circuit}
  \hfill}\vfill
 \hbox to 5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{GII}$}\quad}
 \vskip 2mm
 \hrule width 5cm height .1pt}%
 \vrule width.1pt height 3.8cm depth 0pt}\linebreak[1]}

\def\NgateIO#1 #2#3 #4 #5 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} : a b
   \atpin{#1nI} \lpin{I}  \atpin{#1nI} \atpin{#1nO} \rpin{O}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{GI}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefiv#1 #2 #3#4 #5 #6 #7 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #7\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} #5 r
     \atpin {#1n#5} \lpin{#5}
     \atpin {#1n#6} \rpin{#6}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{SX}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefivNL#1 #2#3 #4 #5 #6 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #6\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} #5 r
     \atpin {#1n#4} \lpin{#4}
     \atpin {#1n#5} \rpin{#5}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{SX}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefiviv#1 #2 #3#4 #5 #6 #7 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
{\hsize4.3cm \footnotesize #7\par}%
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} #5 r
     \atpin {#1n#5} \lpin{#5}
     \atpin {#1n#6} \rpin{#6}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{SO}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefivivNL#1 #2#3 #4 #5 #6 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
{\hsize4.3cm \footnotesize #6\par}%
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} #5 r
     \atpin {#1n#4} \lpin{#4}
     \atpin {#1n#5} \rpin{#5}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{SO}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefo#1 #2 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #2\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{OP}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\optionline#1 {\vskip3mm
  {\large Symbols provided by the option \fbox{\tt#1.def}}\\[3mm]}

\def\bbdef#1 #2#3 #4 {\noindent
\hbox{\vbox to 4.5cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #4\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname n {text} : a b c d
   \atpin{#1nP1} \lpin{P1}
   \atpin{#1nP2} \bpin{P2}
   \atpin{#1nP4} \tpin{P4}
   \atpin{#1nP3} \rpin{P3}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{BXT}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 4.5cm depth 0pt}\linebreak[1]}

\def\bbdefNeT#1 #2#3 #4 #5 {\noindent
\hbox{\vbox to 4.5cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname n : a b c d
   \atpin{#1nP1} \lpin{P1}
   \atpin{#1nP3} \rpin{P3}
   \atpin{#1nP2} \bpin{P2}
   \atpin{#1nP4} \tpin{P4}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{BX}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 4.5cm depth 0pt}\linebreak[1]}

\def\bbdefNeTii#1 #2#3 #4 #5 {\noindent
\hbox{\vbox to 4.5cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname n : a b c d h
   \atpin{#1nP1} \lpin{P1}
   \atpin{#1nP3} \rpin{P3}
   \atpin{#1nP2} \bpin{P2}
   \atpin{#1nP4} \tpin{P4}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{BX}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 4.5cm depth 0pt}\linebreak[1]}

\def\sbdef#1 #2#3 #4 #5 {\noindent
\hbox{\vbox to 4.5cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #5\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname n : a b c d h
   \atpin{#1nP1} \lpin{P1}
   \atpin{#1nP3} \rpin{P3}
   \atpin{#1nP2} \bpin{P2}
   \atpin{#1nP4} \tpin{P4}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{BX}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 4.5cm depth 0pt}\linebreak[1]}

\def\textdef#1 #2 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #2\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0
   \at 0 0 \P1 \at 6 0 \P2
   \csname #1\endcsname {text} from P1 to P2 \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{TXT}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\cdefviii#1 #2 #3#4 #5 #6 #7 #8 {\noindent
\hbox{\vbox to 3cm{\vskip 2mm
{\hsize4.3cm \footnotesize #8\par}%
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname{n} {text} : l
     \atpin {#1n#5} \rpin{#5}
     \atpin {#1n#6} \lpin{#6}
     \atpin {#1n#7} \rpin{#7}
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{S\mathrm{3}P}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 3cm depth 0pt}\linebreak[1]}

\def\Ccirc#1 #2 #3#4{\noindent
  \def\Clpin##1{\atpin{#1n##1} \lpin{##1} }
  \def\Crpin##1{\atpin{#1n##1} \rpin{##1} }
\hbox{\vbox to 4.5cm{\vskip 2mm
 {\hsize 4.3cm \footnotesize #3\par}
 \vfill
 \hbox to 4.5cm{\hfill
   \begin{circuit}0 \csname #1\endcsname n {text} #2 {} #4
   \end{circuit}
  \hfill}\vfill
 \hbox to 4.5cm{~~{\tt\backslash#1}\quad\hfill
                   \fbox{$\mathcal{IC}$}\quad}
 \vskip 2mm
 \hrule width 4.5cm height .1pt}%
 \vrule width.1pt height 4.5cm depth 0pt}\linebreak[1]}
%\iffalse
%</docsty>
%\fi
%^^A last update: Fri  03-13-1998
% \newpage
% {\Large\bf The code of \CIRC.}\\\vskip 1mm
%    \begin{macrocode}
%<*code>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{circ}
    [1997/04/23 v1.0d for typeset circuit diagrams]
\DeclareOption*{\InputIfFileExists{\CurrentOption.def}{}%
  {\PackageError{CIRC}{File \CurrentOption.def not found.}%
                {Check spelling or think about the
                location of file.\MessageBreak
                I tried to load macros for the CIRC package.}}}
%    \end{macrocode}
%
% Sorry, but it's better to stop here.
% The sourcecode is formatted worst. \endinput
%
% F"ur die interne Namensgebung m"ussen einige Zeichen
% in ihrem Kategoriekode als Buchstaben (11) eingetragen werden.
% Der jetzige Kode wird in Definitionen abgelegt.
% Das betrifft die Zeichen \verb+* [ ] @+.
%
%    \begin{macrocode*}
\def\freecirc{\chardef\CIRCinternals\the\catcode`\*\catcode`\*=11
              \chardef\cc@lb\the\catcode`\[
              \chardef\cc@rb\the\catcode`\]
              \chardef\cc@at\the\catcode`\@
              \catcode`\[=11\catcode`\]=11\catcode`\@=11 }
\def\protectcirc{\catcode`\[=\cc@lb\catcode`\]=\cc@rb\catcode`\@=\cc@at
                 \catcode`\*=\CIRCinternals\relax}
\freecirc
%    \end{macrocode*}
%^^A last update: Fri  03-13-1998
% Zu Testzwecken kann "uber \verb+\showpointstrue+ die
% Anzeige aller definierter Anschlu"spunkte eingestellt werden.
%    \begin{macrocode}
\newif\ifshowpoints
\showpointsfalse
%    \end{macrocode}
%
% Alle mit * gekennzeichneten Schalter werden nach jeder Zeichenoperation
% auf den entsprechenden Standardwert gesetzt.
%
% Die Darstellung der Beschriftung mit Schaltzeichentyp und Nummer
% wird "uber \verb+\iflab+ getsteuert. *
%    \begin{macrocode}
\newif\iflab*
\lab*true
%    \end{macrocode}
%
% Schaltzeichenwerte k"onnen auch ausgeblendet werden. *
%    \begin{macrocode}
\newif\ifval*
\val*true
%    \end{macrocode}
%
% Die  Zeichenrichtung wird durch \verb+\ifld+ bestimmt.
%    \begin{macrocode}
\newif\ifld*
\ld*false
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifcc*
\cc*false
%    \end{macrocode}
%
%
%    \begin{macrocode}
\newif\ifpin
\pintrue
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifxoutofgrid
\newif\ifyoutofgrid
\xoutofgridfalse
\youtofgridfalse
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifcen*
\cen*false
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifhvcen*
\hvcen*false
%    \end{macrocode}
\newif\ifcheck*
%
% F"ur die Ermittlung der kleinsten Umschlie"senden Box werden die
% beiden Variablen \verb+\X*max+ und \verb+\X*min+ bei jeder
% Zeichenoperation aktualisiert. Sie enthalten die minimale und die
% maximale Ausdehnung der Zeichenfl"ache in horizontaler Richtung.
%    \begin{macrocode}
\newdimen\X*max
\newdimen\X*min
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\*X*
\newdimen\*Y*
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\**X
\newdimen\**Y
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\***X
\newdimen\***Y
%    \end{macrocode}
%
%  In der Box \verb+\*bbox+ wird f"ur eine Zeichenoperation
%  das entsprechende horizontale Material gesammelt.
%  Diese Box wird dann durch \verb+\put*bbox+ entsprechend
%  der aktuellen Zeichenposition in die Box der entstehenden
%  Zeichnung "ubernommen.
%    \begin{macrocode}
\newbox\*bbox
%    \end{macrocode}
%
%    \begin{macrocode}
\newbox\box*
\newdimen\ic*
\newdimen\ht*
\newdimen\wd*
\newdimen\dp*
%
\newcount\cc*
\newdimen\*spc
\newtoks\ldd*   %linke untere Beschriftung
\newtoks\rud*   %rechte obere Beschriftung
%
\newtoks\llpos*
\newtoks\ldpos*
\newtoks\rlpos*
\newtoks\rdpos*
\newtoks\ulpos*
\newtoks\udpos*
\newtoks\dlpos*
\newtoks\ddpos*
%
\newcount\cnta*
\newcount\cntb*
%
\newtoks\name*  %Bauelementname
\newtoks\ld*pin   %Bezeichnung linker Anschlu"s
\newtoks\ru*pin   % ...
\newtoks\m*pin    % ...
%    \end{macrocode}
%
\newtoks\rmacros
%
%    \begin{macrocode}
\newdimen\outerspace
%    \end{macrocode}
%
%    \begin{macrocode}
\newtoks\*Ilist
\newtoks\*Olist
%    \end{macrocode}

%    \begin{macrocode}
\newdimen\pin*spc
\newdimen\pin*ind
\newdimen\io*ind
\newdimen\mid*ind
\newdimen\pinnum*spc
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
\def\CIRCredef{}
\def\safedef#1{\expandafter\ifx\csname#1\endcsname\relax
\toks0{\expandafter\def\csname#1\endcsname}\else
\edef\CIRCredef{\CIRCredef\expandafter\string\csname#1\endcsname\space}%
\toks0{\expandafter\def\csname.#1.\endcsname}\rmacros
\expandafter{\the\rmacros\let}\rmacros\expandafter\expandafter\expandafter
{\expandafter\the\expandafter\rmacros\csname#1\endcsname}\rmacros\expandafter
\expandafter\expandafter
{\expandafter\the\expandafter\rmacros\csname.#1.\endcsname}\fi
\the\toks0}
\def\safedefs#1{\expandafter\ifx\csname#1\endcsname\relax
\toks0{\expandafter\def\csname#1\endcsname}\else
\edef\CIRCredef{\CIRCredef\expandafter\string\csname#1\endcsname\space}%
\toks0{\expandafter\def\csname.#1.\endcsname}\rmacros
\expandafter{\the\rmacros\let}\rmacros\expandafter\expandafter\expandafter
{\expandafter\the\expandafter\rmacros\csname#1\endcsname}\rmacros\expandafter
\expandafter\expandafter
{\expandafter\the\expandafter\rmacros\csname.#1.\endcsname}\fi
\the\toks0 }
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\getc*#1 {\advance\cc* by #1%
  \ifcc*
     \toks0\ldd*\ldd*\rud*\rud*\toks0
     \ifval*
       \iflab*\val*true\else\val*false\fi
       \lab*true
     \else
       \iflab*\val*true\else\val*false\fi
      \lab*false
     \fi
  \fi
  \global\setbox\box*=\hbox{\char\cc*\/\global\ic*=\lastkern\unkern}%
  \global\ht*\ht\box*\global\wd*\wd\box*\global\dp*\dp\box*}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\check*max#1{\dimen0=#1\advance\dimen0\*X*
               \ifdim\dimen0>\X*max\global\X*max\dimen0\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\check*X{\ifcheck*\ifdim\*X*<\X*min\global\X*min\*X*\fi
                      \ifdim\*X*>\X*max\global\X*max\*X*\fi\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\check*min#1{\dimen0=-#1\advance\dimen0\*X*
               \ifdim\dimen0<\X*min\global\X*min\dimen0\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\check*#1{\check*min{#1}\check*max{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\check*cen{\ifcen*\errhelp{Use `\hcenterto' or `\vcenterto'.}%
  \errmessage{You can't use `\string\centerto' to center `\the\name*'}\fi}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%  Jede Zeichenoperation ruft \verb+\put*box+ auf, dieses
%  Makro setzt die Box \verb+\*bbox+ an die aktuelle Zeichenposition.
%    \begin{macrocode}
\def\put*box{\hbox to 0pt{\kern\*X*\raise\*Y*\box\*bbox\hss}}
%    \end{macrocode}
%
%
%  In Erweiterung zu \verb+\llap+ und \verb+\rlap+ werden
%  hier weitere Abk"urzungen definiert.
%    \begin{macrocode}
\def\hc*#1{\hbox to 0pt{\hss#1\hss}}
\def\vc*#1{\vbox to 0pt{\vss#1\vss}}
\def\tlap#1{\vbox to 0pt{\vss#1}}
\def\blap#1{\vbox to 0pt{#1\vss}}
\def\ac*#1{\vc*{\hc*{#1}}}
%    \end{macrocode}
%
%
%  Zur"ucksetzen der auf eine Zeichenoperation wirkenden Schalter.
%    \begin{macrocode}
\def\reset*ifs{\ld*false\cen*false\hvcen*false\lab*true\val*true\cc*false}
%    \end{macrocode}
%
% Das Kernmakro f"ur die Speicherung von Anschlu"spunkten.
%    \begin{macrocode}
\def\store*XY#1{\ifshowpoints\message{#1}\fi
  \expandafter\xdef\csname#1\endcsname{\*X*\the\*X*\*Y*\the\*Y*}}
%    \end{macrocode}
%
% Retten der aktuellen Zeichenposition.
%    \begin{macrocode}
\def\save*XY{\**X\*X*\**Y\*Y*}
\def\save*xy{\***X\*X*\***Y\*Y*}
%    \end{macrocode}
%
% Wiederherstellen der aktuellen Zeichenposition
%    \begin{macrocode}
\def\restore*XY{\*X*\**X\*Y*\**Y}
\def\restore*xy{\*X*\***X\*Y*\***Y}
%    \end{macrocode}
%
% Abstand zwischen dem gespeichertem Punkt und dem aktuellen
% in x- und y-Richtung bestimmen
%    \begin{macrocode}
\def\diff*XY{\advance\**X-\*X*\advance\**Y-\*Y*}
%    \end{macrocode}
%
% Zentrierung auf angegebenes Schaltzeichen einschalten.
% Richtung ist durch die folgende Zeichenoperation bestimmt.
%    \begin{macrocode}
\def\centerto#1 {\cen*true\save*XY\frompin#1: }
%    \end{macrocode}
%
% Zentrierung auf angegebenes Schaltzeichen einschalten.
% Die aktuelle y-Position wird beibehalten.
%    \begin{macrocode}
\def\hcenterto#1 {\hvcen*true\**Y\*Y*\frompin#1: \*Y*\**Y}
%    \end{macrocode}
%
% Zentrierung auf angegebenes Schaltzeichen einschalten.
% Die aktuelle x-Position wird beibehalten.
%    \begin{macrocode}
\def\vcenterto#1 {\hvcen*true\**X\*X*\frompin#1: \*X*\**X}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\do*Ilist{\ifshowpoints\message{|<}\fi
  \check*true
  \save*XY\the\*Ilist\ifshowpoints\message{>|}\fi\restore*XY\*Ilist={}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\shift*Ilist#1{\ifshowpoints\message{|<}\fi
  \check*false
  \save*XY\the\*Ilist\frompin{\the\name*#1}
  \ifshowpoints\message{| shift \the\name*#1 |}\fi
  \advance\**X\**X\advance\**X-\*X*\*X*\**X
  \advance\**Y\**Y\advance\**Y-\*Y*\*Y*\**Y
  \check*true
  \save*XY\the\*Ilist\restore*XY
  \ifshowpoints\message{>|}\fi\*Ilist={}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\shift*IOlist#1{\ifshowpoints\message{|<}\fi
  \check*false
  \save*XY\the\*Ilist\restore*XY\advance\*X*\wd\*bbox\the\*Olist
  \frompin{\the\name*#1}
  \ifshowpoints\message{| shift \the\name*#1 |}\fi
  \advance\**X\**X\advance\**X-\*X*\*X*\**X
  \advance\**Y\**Y\advance\**Y-\*Y*\*Y*\**Y
  \check*true
  \save*XY\the\*Ilist\restore*XY\advance\*X*\wd\*bbox\the\*Olist
  \restore*XY\ifshowpoints\message{>|}\fi\*Ilist={}\*Olist={}}
%    \end{macrocode}
%
% \Ladd*x  erweitert die Tokenliste \argi um Makros, die das
% Dimensionsregister \XXX um \argii erh"ohen.
% \argii wird als aktueller
% Zahlenwert in die Tokenliste "ubernommen, \argiii wird
% expandiert.
%    \begin{macrocode}
\def\Ladd*x#1#2{\dimen9=#2%
  \edef\next{{\the#1\advance\*X*\the\dimen9 }}%
  \global#1\next}
%    \end{macrocode}
%
% \Ladd*y  ist \verb+\Ladd*x+ in seiner Funktion gleich, das Makro
% ver"andert jedoch \YYY.
%    \begin{macrocode}
\def\Ladd*y#1#2{\dimen9=#2%
  \edef\next{{\the#1\advance\*Y*\the\dimen9 }}%
  \global#1\next}
%    \end{macrocode}
%
% \Lstore* f"ugt in die Tokenliste \argi Makros ein, die die Position unter
% \argii speichern.
%    \begin{macrocode}
\def\Lstore*#1#2{\edef\next{{\the#1\noexpand\store*XY{\the\name*#2}}}%
  \global#1\next}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\Lstopos*#1{\global#1\expandafter{\the#1\save*xy}}
\def\Lrstpos*#1{\global#1\expandafter{\the#1\restore*xy}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\LX*check#1{\global#1\expandafter{\the#1\check*X}}
%    \end{macrocode}
%
% Die folgenden Makros sind schon auf die Tokenliste \verb+\*Ilist+
% festgelegt, da fast alle Anschlu"sdefinitionen nur eine Liste
% benutzen.
%    \begin{macrocode}
\def\add*x{\Ladd*x\*Ilist}
\def\add*y{\Ladd*y\*Ilist}
\def\store*{\Lstore*\*Ilist}
\def\stopos*{\Lstopos*\*Ilist}
\def\rstpos*{\Lrstpos*\*Ilist}
\def\X*check{\LX*check\*Ilist}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\Cadd*#1{\Ladd*y#1{-\pin*spc}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\Cstore*#1#2{\ifx{#2}*\else\Lstore*#1{#2}\fi}
%    \end{macrocode}
%
%  Um einen Anschlu"spunkt zur neuen Zeichenposition zu erkl"aren,
%  wird nur das entsprechende Makro aufgerufen, nachdem zuvor
%  getestet wurde ob es existiert.
%    \begin{macrocode}
\def\frompin#1 {\expandafter\ifx\csname#1\endcsname\relax
  \errhelp{Check spelling! Look up in the description of circuits.}%
  \errmessage{Point >#1< is not defined}\else\csname#1\endcsname\fi}
%    \end{macrocode}
%
% F"ur eine sch"onere Lesbarkeit wird neben {\em von Punkt}
% auch noch {\em am Punkt} definiert.
%    \begin{macrocode}
\let\atpin\frompin
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\h*twopins#1{\getc*#1 \ifcen*\*Y*\**Y\hvcen*true\fi
\wd\box*=.5\wd*
\advance\ht*\*spc
%
\X*check\store*{\the\ld*pin}\add*x{.5\wd*}\store*:\add*x{.5\wd*}%
\store*{\the\ru*pin}\X*check
\ifhvcen*\shift*Ilist:\else\ifld*\shift*Ilist{\the\ru*pin}\else\do*Ilist\fi\fi
%
\labelfont
\setbox0=\hbox{\the\rud*}\setbox1=\hbox{\the\ldd*}%
\**X\*X*\advance\*X*.5\wd*
\iflab*\check*{.5\wd0}\fi%
\ifval*\check*{.5\wd1}\fi%
\*X*\**X
%
\setbox\*bbox=\hbox{\box\box*
  \iflab*\raise\ht*\hc*{\unhbox0}\fi
  \ifval*\lower\dp*\vtop{\kern\*spc\hc*{\unhbox1}}\fi
  \add*cmds}%
\put*box
\ifld*\else\advance\*X*\wd*\fi\reset*ifs}
%    \end{macrocode}
%
%
%
%    \begin{macrocode}
\def\v*twopins#1{\getc*#1 \ifcen*\*X*\**X\hvcen*true\fi
%
\labelfont
\setbox0=\hbox{\ifval*\the\ldd*\kern\*spc\fi\kern\dp*}\dimen1\wd0
\setbox1=\hbox{\kern\wd*\iflab*\kern\*spc\the\rud*\fi}\dimen0\wd1
\dp0=0pt\dp1=0pt
%
\wd\box*=0pt\dp\box*=0pt
\setbox\*bbox=\hbox{\box\box*
  \raise.5\ht*\hbox{\vc*{\hbox{\llap{\box0}\rlap{\box1}}}\add*cmds}}%
%
\store*{\the\ld*pin}\add*y{.5\ht*}\store*:\add*y{.5\ht*}\store*{\the\ru*pin}%
\ifhvcen*\shift*Ilist:\else\ifld*\shift*Ilist{\the\ru*pin}\else\do*Ilist\fi\fi
%
\check*X
\check*max{\dimen0}%
\check*min{\dimen1}%
%
\put*box
\ifld*\else\advance\*Y*\ht*\fi\reset*ifs}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\ii*#1 {\if#1h\ld*pin{l}\ru*pin{r}\h*twopins0\relax\else
            \if#1v\ld*pin{b}\ru*pin{t}\v*twopins1\relax\else
            \if#1u\ld*pin{b}\ru*pin{t}\v*twopins1\relax\else
            \if#1d\ld*pin{b}\ru*pin{t}\ld*true\v*twopins1\relax\else
            \if#1l\ld*pin{l}\ru*pin{r}\ld*true\h*twopins0\relax\else
            \if#1r\ld*pin{l}\ru*pin{r}\h*twopins0\relax\else
                  \errhelp{Direction >h<, >v<, >l<, >u<, >r< or >d< expected.}%
                  \errmessage{Bad direction specified! You typed:>#1<.}%
                  \fi\fi\fi\fi\fi\fi}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\change*pins{\toks0\ld*pin\ld*pin\ru*pin\ru*pin\toks0}
%    \end{macrocode}
%
\def\CiRCl{1}\def\CiRCr{2}\def\CiRCu{3}\def\CiRCd{4}
\def\CiRCL{5}\def\CiRCR{6}\def\CiRCU{7}\def\CiRCD{8}
\def\CIRCiErr{\PackageError{CIRC}{Internal Error}%
              {You are great, please send all files to the author and wait for
               answer.}}
%    \begin{macrocode}
\def\iv*#1 #2 {\cnta*=0\csname CiRC#2\endcsname\relax
               \ifnum\cnta*=0
               \PackageError{CIRC}{Bad direction}%
                 {Please check spelling}\fi
               \ifcase\CIRCpintoN{#1}\relax\CIRCiErr \or
                 \ifcase\cnta*
                 \CIRCiErr\or\<\change*pins\h*twopins2\relax
                               \or\h*twopins0\relax
                               \or\v*twopins1\relax
                               \or\change*pins\<\v*twopins3\relax\else
                 \PackageError{CIRC}{Bad direction}%
                   {Please check spelling, only [l r u d] expected}\fi\or
                 \ifcase\cnta*
                 \CIRCiErr\or\<\h*twopins0\relax
                          \or\change*pins\h*twopins2\relax
                          \or\change*pins\v*twopins3\relax
                          \or\<\v*twopins1\relax\else
                 \PackageError{CIRC}{Bad direction}%
                   {Please check spelling, only [l r u d] expected}\fi\fi}
\def\iviv*#1 #2 {\cnta*=0\csname CiRC#2\endcsname\relax
               \ifnum\cnta*=0
               \PackageError{CIRC}{Bad direction}%
                 {Please check spelling}\fi
               \ifcase\CIRCpintoN{#1}\relax\CIRCiErr \or
                 \ifcase\cnta*
                 \CIRCiErr\or\<\change*pins\h*twopins6\relax
                          \or\h*twopins0\relax
                          \or\v*twopins5\relax
                          \or\change*pins\<\v*twopins3\relax
                          \or\<\change*pins\h*twopins2\relax
                          \or\h*twopins4\relax
                          \or\v*twopins1\relax
                          \or\change*pins\<\v*twopins7\relax\fi\or
                 \ifcase\cnta*
                 \CIRCiErr\or\<\h*twopins0\relax
                          \or\change*pins\h*twopins6\relax
                          \or\change*pins\v*twopins3\relax
                          \or\<\v*twopins5\relax
                          \or\<\h*twopins4\relax
                          \or\change*pins\h*twopins2\relax
                          \or\change*pins\v*twopins7\relax
                          \or\<\v*twopins1\relax\fi\fi}
%
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\lviii*#1{\store*{\the\m*pin}\X*check
              \add*x\wd*\stopos*\add*y{-\dp*}\store*{\the\ld*pin}\X*check
              \rstpos*\add*y\ht*\store*{\the\ru*pin}\rstpos*
              \dimen0\ht*\advance\dimen0-\dp*\add*y{.5\dimen0}\store*:
              \rstpos*\add*x\ic*\X*check
              \ifhvcen*\shift*Ilist:\else\shift*Ilist{#1}\fi
              \setbox\*bbox=\hbox{\labelfont
                \the\llpos*\box\box*\the\ldpos*}\put*box}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\rviii*#1{\store*{\the\m*pin}\X*check
              \add*x{-\wd*}\stopos*\add*y\ht*\store*{\the\ru*pin}\X*check
              \rstpos*\add*y{-\dp*}\store*{\the\ld*pin}\rstpos*
              \dimen0\ht*\advance\dimen0-\dp*\add*y{.5\dimen0}\store*:
              \rstpos*\add*x{-\ic*}\X*check
              \ifhvcen*\shift*Ilist:\else\shift*Ilist{#1}\fi
              \setbox\*bbox=\hbox{\labelfont
                \the\rdpos*\box\box*\the\rlpos*}\put*box}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\dviii*#1{\store*{\the\m*pin}%
              \add*y\dp*\stopos*\add*x\ic*\store*{\the\ru*pin}\X*check
              \rstpos*\add*x{-\wd*}\store*{\the\ld*pin}\X*check
              \rstpos*\dimen0-\wd*\advance\dimen0\ic*\add*x{.5\dimen0}\store*:
              \ifhvcen*\shift*Ilist:\else\shift*Ilist{#1}\fi
              \wd\box*=0pt\dp\box*=0pt
              \setbox\*bbox=\hbox{\labelfont
                \the\dlpos*\box\box*\the\ddpos*}\put*box}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\uviii*#1{\store*{\the\m*pin}%
              \add*y{-\ht*}\stopos*\add*x\ic*\store*{\the\ru*pin}\X*check
              \rstpos*\add*x{-\wd*}\store*{\the\ld*pin}\X*check
              \rstpos*\dimen0-\wd*\advance\dimen0\ic*\add*x{.5\dimen0}\store*:
              \ifhvcen*\shift*Ilist:\else\shift*Ilist{#1}\fi
              \wd\box*=0pt\ht\box*=0pt
              \setbox\*bbox=\hbox{\labelfont
                \the\ulpos*\box\box*\the\udpos*}\put*box}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\viii*#1 #2 {\check*cen
                 \if#2l            \getc*0 \lviii*{#1}\else
                 \if#2r            \getc*1 \rviii*{#1}\else
                 \if#2d            \getc*3 \dviii*{#1}\else
                 \if#2u            \getc*2 \uviii*{#1}\else
                 \if#2L\change*pins\getc*4 \lviii*{#1}\else
                 \if#2R\change*pins\getc*5 \rviii*{#1}\else
                 \if#2D\change*pins\getc*7 \dviii*{#1}\else
                 \if#2U\change*pins\getc*6 \uviii*{#1}\else
                 \errhelp{Direction >l<, >r<, >u<, >d<, >L<, >R<, >U< or >D<
                          expected.}%
                 \errmessage{Bad direction >#2<}\fi\fi\fi\fi\fi\fi\fi\fi
                 \reset*ifs}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%
%
\def\CIRCpintoN#1{\if\the\ld*pin#1 1\else
                   \if\the\ru*pin#1 2\else
                    \if\the\m*pin#1 3\else
                      \PackageError{CIRC}{Bad pin name}%
                      {Please check spelling or look up in the documentation}
\fi\fi\fi}
%
%    \begin{macrocode}
\def\cdef#1 #2 #3#4 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{$#2_{##1}$}\ldd*{##2}\cc*#4 #3\ii*}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\cdefiv#1 #2 #3#4 #5 #6 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{$#2_{##1}$}\ldd*{##2}\m*pin{@}%
   \ld*pin{#5}\ru*pin{#6}\cc*#4 #3\iv*}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\cdefivNL#1 #2#3 #4 #5 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{}\ldd*{##2}\ld*pin{#4}\ru*pin{#5}\m*pin{@}%
   \cc*#3 #2\iv*}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\cdefiviv#1 #2 #3#4 #5 #6 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{$#2_{##1}$}\ldd*{##2}\ld*pin{#5}\ru*pin{#6}\m*pin{@}%
   \cc*#4 #3\iviv*}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\cdefivivNL#1 #2#3 #4 #5 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{}\ldd*{##2}\ld*pin{#4}\ru*pin{#5}\m*pin{@}%
   \cc*#3 #2\iviv*}}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\cdefNL#1 #2#3 {\safedef{#1}##1 ##2 {%
   \name*{#1##1}\rud*{}\ldd*{##2}\cc*#3 #2\ii*}}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\cdefviii#1 #2 #3#4 #5 #6 #7 {\safedef{#1}##1 ##2 {\name*{#1##1}%
   \rud*{$#2_{##1}$}\ldd*{##2}\ld*pin{#5}\m*pin{#6}\ru*pin{#7}\cc*#4 #3\viii*}}
%    \end{macrocode}
%    \begin{macrocode}
\def\cwdef#1 #2 {\safedef{#1}##1 ##2 {\cc*#2
                 \cnta*##1\toks2{}\toks4{}\dimen2=##1em\test*xygrid
                 \csname line*##2\endcsname}}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\black*boxii#1 #2 #3 #4 #5 #6 #7 {\check*cen
  \if#7h\getc*0
  \store*{P1}\X*check\add*x{.5\wd*}\stopos*\X*check\store*:
  \add*y\ht*\store*{P4}\rstpos*\add*y{-\dp*}\store*{P2}\rstpos*
  \add*x{.5\wd*}\X*check\store*{P3}%
  \ifhvcen*\shift*Ilist:\else\shift*Ilist{#2}\fi
  \setbox\*bbox=\hbox{\ifpin\pinnumberfont
    \setbox0=\hbox{#3\kern\*spc}\check*min{\wd0}%
    \raise\pinnum*spc\llap{#3\kern\*spc}%
    \setbox0=\hbox{\kern\*spc\kern\wd*#5}\check*max{\wd0}\wd0=0pt
    \raise\pinnum*spc\box0
    \setbox0=\hbox{\kern\pinnum*spc\kern.5\wd*#6}\check*max{\wd0}\wd0=0pt
    \dimen0\ht*\advance\dimen0\*spc
    \raise\dimen0\box0
    \setbox0=\hbox{\kern\pinnum*spc\kern.5\wd*#4}\check*max{\wd0}\wd0=0pt
    \dimen0\dp*\advance\dimen0\*spc
    \lower\dimen0\vtop{\kern0pt\box0}\fi
    \hc*{\kern\wd*\ctextfont\vc*{\hbox{#1}}}\box\box*}\put*box\reset*ifs
  \else\if#7v\getc*1
  \store*{P4}\X*check\add*x{.5\wd*}\stopos*\X*check\store*:
  \add*y\ht*\store*{P3}\rstpos*\add*y{-\dp*}\store*{P1}\rstpos*
  \add*x{.5\wd*}\X*check\store*{P2}%
  \ifhvcen*\shift*Ilist:\else\shift*Ilist{#2}\fi
  \setbox\*bbox=\hbox{\ifpin\pinnumberfont
    \setbox0=\hbox{#6\kern\*spc}\check*min{\wd0}%
    \raise\pinnum*spc\llap{#6\kern\*spc}%
    \setbox0=\hbox{\kern\*spc\kern\wd*#4}\check*max{\wd0}\wd0=0pt
    \raise\pinnum*spc\box0
    \setbox0=\hbox{\kern\pinnum*spc\kern.5\wd*#5}\check*max{\wd0}\wd0=0pt
    \dimen0\ht*\advance\dimen0\*spc
    \raise\dimen0\box0
    \setbox0=\hbox{\kern\pinnum*spc\kern.5\wd*#3}\check*max{\wd0}\wd0=0pt
    \dimen0\dp*\advance\dimen0\*spc
    \lower\dimen0\vtop{\kern0pt\box0}\fi
    \hc*{\kern\wd*\ctextfont\vc*{\hbox{#1}}}\box\box*}\put*box\reset*ifs
  \else\errhelp{Direction >h< or >v< expected.}%
  \errmessage{ >#1<  Bad direction specified}\fi\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\black*box#1 #2 #3 #4 #5 #6 {\black*boxii{#1} {#2} {#3} {#4} {#5} {#6} h }
%    \end{macrocode}
%
%    \begin{macrocode}
\def\sym*box#1 #2 {\check*cen
  \getc*0
  \store*{P1}\X*check\stopos*
  \add*x{.5\wd*}\store*:\add*x{.5\wd*}\store*{P3}\X*check\rstpos*
  \add*y{-1em}\store* b
  \add*x{\wd*}\store* e\rstpos*
  \add*y{1em}\store* a
  \add*x{\wd*}\store* f\rstpos*
  \add*x{.5\wd*}\stopos*
  \add*y\ht*\store*{P4}%
  \add*x{1em}\store* g
  \rstpos*\add*y\ht*
  \add*x{-1em}\store* h
  \rstpos*\add*y{-\dp*}\store*{P2}%
  \add*x{1em}\store* d
  \rstpos*\add*y{-\dp*}%
  \add*x{-1em}\store* c
  \ifhvcen*\shift*Ilist:\else\shift*Ilist{#2}\fi
  \setbox\*bbox=
    \hbox{\hc*{\kern\wd*\ctextfont\vc*{\hbox{#1}}}\box\box*}\put*box
    \reset*ifs}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\bbdef#1 #2#3 {\safedef{#1}##1
{\name*{#1##1}\cc*#3 #2\black*box}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\bbdefNeT#1 #2#3 #4 {\safedef{#1}##1
{\name*{#1##1}\cc*#3#2\black*box{#4} }}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\bbdefNeTii#1 #2#3 #4 {\safedef{#1}##1
{\name*{#1##1}\cc*#3#2\black*boxii{#4} }}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\sbdef#1 #2#3 #4 {\safedef{#1}##1
{\name*{#1##1}\cc*#3#2\sym*box{#4} }}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
% ^^A beschr p l1 l2 l3
%
% ^^A\cc*
% ^^A\name*
% ^^A\**pin
% ^^A\ldd* -> innenbeschriftung
%
%</code>
%<+gate>\ProvidesFile{gate.def}
%<+gate>\freecirc
%<*gate>
%    \begin{macrocode}
\def\g*iio#1 #2 #3 #4 #5 {\dimen4\*X*\dimen5\*Y*
  \rud*{#1}\getc*0
  \stopos*\add*y\ic*\X*check\store*{\the\ru*pin}\rstpos*
  \add*y{-\ic*}\store*{\the\ld*pin}\rstpos*
  \add*x{.5\wd*}\store*:\add*x{.5\wd*}\X*check\store*{\the\m*pin}%
  \ifhvcen*\shift*Ilist:\else\shift*Ilist{#2}\fi
  \setbox\*bbox=\hbox{\ifpin\pinnumberfont
    \dimen0\ic*\advance\dimen0\pinnum*spc
    \raise\dimen0\rlap{\kern\pin*ind\hc*{#3}}%
    \dimen0-\ic*\advance\dimen0\pinnum*spc
    \raise\dimen0\rlap{\kern\pin*ind\hc*{#4}}%
    \raise\pinnum*spc\rlap{\kern\wd*\kern-\pin*ind\hc*{#5}}\fi
    \the\ldd*\box\box*}\put*box\reset*ifs
  \*X*\dimen4\*Y*\dimen5}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\g*io#1 #2 #3 #4 {\dimen4\*X*\dimen5\*Y*
  \rud*{#1}\getc*0
  \store*{\the\ld*pin}%
  \add*x{.5\wd*}\store*:\add*x{.5\wd*}\X*check\store*{\the\m*pin}%
  \ifhvcen*\shift*Ilist:\else\shift*Ilist{#2}\fi
  \setbox\*bbox=\hbox{\ifpin\pinnumberfont
    \raise\pinnum*spc\rlap{\kern\pin*ind\hc*{#3}}%
    \raise\pinnum*spc\rlap{\kern\wd*\kern-\pin*ind\hc*{#4}}\fi
    \the\ldd*\box\box*}\put*box\reset*ifs
  \*X*\dimen4\*Y*\dimen5}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\gateIIO#1 #2#3 #4#5 #6 #7 {\expandafter
  \def\csname#1\endcsname##1 {\name*{#1##1}\ldd*{#4}%
    \ld*pin{#5}\m*pin{#6}\ru*pin{#7}\cc*#3 #2\g*iio}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\ldd*gN#1{\raise\fontdimen10\c*fntb
                 \blap{\hc*{\kern\wd*\symfont\,#1}}%
              \lower\dp*
                 \vtop{\kern\*spc\hc*{\labelfont\kern\wd*\the\rud*}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\ldd*OV{\ac*{\kern.8\wd*\ctextfont\the\rud*}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\NgateIIO#1 #2#3 #4 {\expandafter
  \def\csname#1\endcsname##1 {\name*{#1##1}\ldd*{\ldd*gN{#4}}%
    \ld*pin{I2}\m*pin{O}\ru*pin{I1}\cc*#3 #2\g*iio}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\gateIO#1 #2#3 #4#5 #6 {\expandafter
  \def\csname#1\endcsname##1 {\name*{#1##1}\ldd*{#4}%
    \ld*pin{#4}\m*pin{#5}\cc*#3 #2\g*io}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\NgateIO#1 #2#3 #4 {\expandafter
  \def\csname#1\endcsname##1 {\name*{#1##1}\ldd*{\ldd*gN{#4}}%
    \ld*pin{I}\m*pin{O}\cc*#3 #2\g*io}}
%    \end{macrocode}
%</gate>
%<*code>
%^^A last update: Sat  06-13-2003
%</code>
%<*doc>
\input cidoc
\freecirc
\hbox{\circuit0 \CIRCLogo \endcircuit\hskip3cm
  \verb|\CIRCLogo|}\vskip5mm
%</doc>
%<*code,doc>
\cwdef        wire   {128\c*fnt}
%<+doc> {wire}
\cwdef        dashed {120\c*fnt}
%<+doc> {dashed wire}
%<+doc>\cwwdef bundle {bundle}
%<+doc>\cwwdef wwire {double wire}
%<+doc>\textdef Utext {text with arrow}
%<+doc>\textdef centertext {centered text}
%</code,doc>
%<*basic>
\ProvidesFile{basic.def}
\freecirc
\def\GND#1 {\setbox\*bbox=\hbox{\c*fnt\char254}%
  \check*min{\wd\*bbox}\check*max{\wd\*bbox}\put*box
  \store*XY{GND#1}\store*XY{GND#1:}\reset*ifs}
\def\gnd#1 {\setbox\*bbox=\hbox{\c*fnt\char253}%
  \check*min{\wd\*bbox}\check*max{\wd\*bbox}\put*box
  \store*XY{gnd#1}\store*XY{gnd#1:}\reset*ifs}
\def\junction#1 {\setbox\*bbox=\hbox{\c*fnt\char255}\check*{\wd\*bbox}\check*X
                 \put*box\store*XY{.#1:}\store*XY{junction#1:}%
                 \store*XY{junction#1}\store*XY{.#1}\reset*ifs}
%</basic>
%<*basic,doc>
%<+doc>\optionline basic
%<+doc>\cdefo GND ground
%<+doc>\cdefo gnd ground
%<+doc>\cdefo . junction \par
\cdef         R     R     \c*fntw    0
%<+doc> {resistor}
\cdef         Rus   R     \c*fntw   24
%<+doc> {US resistor}
\cdefviii     Rvar  R     \c*fntw    8          . S *
%<+doc> {variable resistor}
\cdefviii     Rusvar R    \c*fntw   32          . S *
%<+doc> {variable resistor}
\cdef         C     C     \c*fntw  128
%<+doc> {capacitor}
\cdef         Cvar  C     \c*fntw  130
%<+doc> {variable capacitor}
\cdefiv       Cel   C     \c*fntw  136          - +
%<+doc> {electrolytic capacitor}
\cdefiv       D     D     \c*fntd    0          K A
%<+doc> {diode}
\cdefiv       ZD    D     \c*fntd    4          K A
%<+doc> {Zener diode}
\cdefiviv     LED   D     \c*fntd    8          K A
%<+doc> {light emitting diode}
\cdefiv       Dcap  D     \c*fntd   16          K A
%<+doc> {capacitance variation diode}
\cdefiv       whatI I     \c*fnt   248          d s
%<+doc> {current flow}
\cdefiv       U     U     \c*fnt    16          + -
%<+doc> {voltage source}
\cdef       varU  U   \c*fnt  44
%<+doc> {voltage source, variant}
\cdef       varI  I   \c*fnt 46
%<+doc> {current source variant}
\cdefiv       Uvar  U     \c*fnt    20          + -
%<+doc> {variable voltage source}
\cdef         I     I     \c*fnt    12
%<+doc> {current source}
\cdef         Ivar  I     \c*fnt    14
%<+doc> {variable current source}
\cdef         V     U     {\def\add*cmds{\clr*acmds
                           \ac*{\symfont V}}\c*fnt}8
%<+doc> {voltmeter}
\cdef         A     I     {\def\add*cmds{\clr*acmds
                           \ac*{\symfont A}}\c*fnt}8
%<+doc> {amperemeter}
\cdefiv       L     L     \c*fnt     0          . *
%<+doc> {coil}
\cdef         xtal  Q     \c*fnt     4
%<+doc> {quartz crystal}
\cdef         La    La    \c*fnt     6
%<+doc> {incandescent lamp} % electric bulb
\cdef         GasLa {}   \c*fnt     40
%<+doc> {gas lamp}
\cdef         S     S     \c*fnt    24
%<+doc> {switch}
\cdefviii     SW    S     \c*fnt    32          o s c
%<+doc> {changeover switch}
\cdefivNL     mconnection \c*fnt   232          o c
%<+doc> {connection (pointed)}
\cdefivNL     connection  \c*fnt   240          o c
%<+doc> {connection (round empty)}
\cdefivNL     fconnection \c*fnt   244          o c
%<+doc> {connection (round full)}
\cdefiviv npnPH T \c*fntt 80 E C
%<+doc> {phototransistor}
\cdefviii     npnEC T     \c*fntt    0          E . C
%<+doc> {npn-transistor without base}
\cdefviii     pnpEC T     \c*fntt    8          E . C
%<+doc> {pnp-transistor without base}
\cdefviii     npn   T     \c*fntt   16          E B C
%<+doc> {npn-transistor}
\cdefviii     pnp   T     \c*fntt   24          E B C
%<+doc> {pnp-transistor}
\cdefviii     nfet  T     \c*fntt   32          S G D
%<+doc> {n-channel field effect transistor}
\cdefviii     pfet  T     \c*fntt   40          S G D
%<+doc> {p-channel field effect transistor}
\cdefviii     nvmos T     \c*fntt   48          S G D
%<+doc> {}
\cdefviii     pvmos T     \c*fntt   56          S G D
%<+doc> {}
\cdefviii     namos T     \c*fntt   64          S G D
%<+doc> {}
\cdefviii     pamos T     \c*fntt   72          S G D
%<+doc> {}
%<+basic>\protectcirc
%</basic,doc>
%<*gate,doc>
%<+doc>\pagebreak
%<+doc>\optionline gate
\gateIIO      OV          \c*fntb  255 \ldd*OV  + O -
%<+doc> {operational amplifier}
\gateIIO      ov          \c*fntb  254 \ldd*OV  - O +
%<+doc> {operational amplifier}
%<+doc>
\NgateIIO     NAND        \c*fntb  132 {$\&$}
%<+doc> {NAND-gate}
\NgateIIO     AND         \c*fntb  131 {$\&$}
%<+doc> {AND-gate}
\NgateIIO     OR          \c*fntb  131 {$\ge$1}
%<+doc> {OR-gate}
\NgateIIO     NOR         \c*fntb  132 {$\ge$1}
%<+doc> {NOR-gate}
\NgateIIO     XOR         \c*fntb  131 {$=$1}
%<+doc> {XOR-gate}
\NgateIIO     XNOR        \c*fntb  131 {$=$\vrule width 0pt height 1.5ex\,}
%<+doc> {XNOR-gate}
\NgateIO      INV         \c*fntb  130 {1\,}
%<+doc> {NOT-gate}
\NgateIO      ST          \c*fntb  128 {{\c*fnts\char7}}
%<+doc> {Schmitt trigger}
\NgateIO      STINV       \c*fntb  130 {{\c*fnts\char7}}
%<+doc> {inverted Schmitt trigger}
\NgateIO      BUF         \c*fntb  130 {{\c*fnts\char25}}
%<+doc> {buffer}
%<+gate>\protectcirc
%</gate,doc>
%<*oldgate,doc>
%<+doc>\optionline oldgate
%<+oldgate>\freecirc
\NgateIIO     oldAND        \c*fntb  133 {}
%<+doc> {old AND-gate}
\NgateIIO    oldNAND         \c*fntb  134 {}
%<+doc> {old NAND-gate}
\NgateIIO     oldOR          \c*fntb  135 {}
%<+doc> {old OR-gate}
\NgateIIO     oldNOR         \c*fntb  136 {}
%<+doc> {old NOR-gate}
\NgateIIO     oldXOR         \c*fntb  137 {}
%<+doc> {old XOR-gate}
%<+oldgate>\protectcirc
%</oldgate,doc>
%<*box,doc>
%<+box>\ProvidesFile{box.def}
%<+box>\freecirc
%<+doc>\optionline box
\bbdef        BBa         \c*fntb  252
%<+doc> {black box analog}
\bbdef        BBd         \c*fntb  253
%<+doc> {black box digital}
%<+doc>\pagebreak
\bbdefNeT oscillograph \c*fnt  142 {}
%<+doc> {oscillograph}
\bbdefNeT G    \c*fntb 250 \vbox{\hc*{\symfont G}\kern1.5\*spc%
                                 \hc*{\c*fnts\char16}}
%<+doc> {generator}
\bbdefNeT Gvar \c*fntb 250 \vbox{\hc*{\symfont G}\kern1.5\*spc%
                                 \hc*{\c*fnts\char17}}
%<+doc> {generator, variable}
\bbdefNeT Impulse \c*fntb 250 \c*fnts\char13
%<+doc> {generator, pulses}
\bbdefNeT Amp  \c*fntb 250 \c*fnts\char24
%<+doc> {amplifier}
\sbdef ACtoDC \c*fntb 251 \hbox{\raise.6\ht*\hbox{\c*fnts\char16}%
                                \lower.6\dp*\hbox{\symfont$=$}}
%<+doc> {AC to DC converter}
%<+box>\protectcirc
%</box,doc>
%<*doc>
\optionline ic
\Ccirc RSFF S {RS flip flop}{\Clpin{S}\Clpin{R}\Crpin{Q}\Crpin{NQ}}
\Ccirc NRSFF S {RS flip flop}{\Clpin{S}\Clpin{R}\Crpin{Q}\Crpin{NQ}}
\Ccirc DFF C {D flip flop}{\Clpin{C}\Clpin{D}\Crpin{Q}\Crpin{NQ}}
\Ccirc JKMSFF R {JK master slave flip flop}{\Clpin{S}\Clpin{J}\Clpin{C}\Clpin{K}\Clpin{R}\Crpin{Q}\Crpin{NQ}}
\Ccirc fff R {timer NE\,555}{\Clpin{IS}\Clpin{IT}\Clpin{R}\Crpin{OK}\Crpin{O}\Crpin{OD}}
\Ccirc NULL i+ {nullor}{\Clpin{i+}\Clpin{i-}\Crpin{o+}\Crpin{o-}}
%</doc>
%^^A last update: Fri  03-13-1998
%<*optics>
% First lets define the header of module OPTICS.
%    \begin{macrocode}
\ProvidesFile{optics.def}
\freecirc
%    \end{macrocode}
%    \begin{macrocode}
\safedef{Dtext}#1 from #2 to #3 {{
  \frompin{#2} \save*XY\frompin{#3} \diff*XY
    \ifdim\**X=0pt
      \dimen0\**Y
      \ifdim\**Y<0pt\dimen0-\dimen0\fi
      \c*fnts\setbox0=\hbox{\char9}\setbox1=\hbox{\char11}%
      \c*fnt\setbox2=\hbox{\char132}\dp1=0pt
        \advance\dimen0-\ht0\calc*u
        \setbox\*bbox=
          \vtop{\box1\loop\ifnum\cntb*>0\copy2
            \advance\cntb*-1\repeat\box0}%
      \put*box\advance\*X*\*spc\advance\*Y*.5\**Y\put\vc*{\hbox{#1}}
    \else
    \ifdim\**Y=0pt
      \advance\*X*\**X
      \dimen0\**X
      \ifdim\**X<0pt\dimen0-\dimen0\fi
        \c*fnts\setbox0=\hbox{\char8}\setbox1=\hbox{\char10}%
        \c*fnt\advance\dimen0-\wd0\calc*u
        \setbox\*bbox=\hbox{\box0\loop\ifnum\cntb*>0\advance\cntb*-1
        \char129\repeat\box1}%
      \put*box\advance\*X*-.5\**X\advance\*Y*\*spc\put\hc*{#1}
    \else\errhelp{Only horizontal or vertical labeling allowed.}%
    \errmessage{Bad points!}\fi\fi}}
%    \end{macrocode}
%
% We need a new font for the optic symbols.
%    \begin{macrocode}
\addCIRCfont cioptic
%    \end{macrocode}
%
%</optics>
%<*optics,doc>
%<+doc>\optionline optics
%<+doc>\textdef Dtext {text measuring a length}
%    \begin{macrocode}
\cwdef     oa          {128\CIRCcioptic}
%<+doc> {optical axis}
\cdef      SLens    L  \CIRCcioptic   0
%<+doc> {thin lens}
\cdefiv    HSLens   L  \CIRCcioptic   2 | )
%<+doc> {half thin lens}
\cdef      BLens    L  \CIRCcioptic   6
%<+doc> {thick lens}
\cdefiv    HBLens   L  \CIRCcioptic   8 | )
%<+doc> {half thick lens}
\cdef      VLens    L  \CIRCcioptic  12
%<+doc> {concave lens}
\cdefiv    HVLens   L  \CIRCcioptic  14 | (
%<+doc> {half concave lens}
\cdefviii  Mirror   M  \CIRCcioptic  85 * . +
%<+doc> {mirror}
\cdefviii  BSplit   BS \CIRCcioptic  36 * . +
%<+doc> {beam splitter}
\cdef      Polar    P  \CIRCcioptic  44
%<+doc> {polarizer}
\cdef      Pinhole  {} \CIRCcioptic  46
%<+doc> {pinhole}
\cdefiv    Cam      {} \CIRCcioptic  66  . |
%<+doc> {camera}
\cdef      ScrL     {} \CIRCcioptic  72
%<+doc> {screen, look at the left side}
\cdef      ScrR     {} \CIRCcioptic  74
%<+doc> {screen, look at the right side}
\cdef      ScrBL    {} \CIRCcioptic  76
%<+doc> {screen, look behind the left side}
\cdef      ScrBR    {} \CIRCcioptic  78
%<+doc> {screen, look behind the right side}
\cdef      ScrTL    {} \CIRCcioptic  80
%<+doc> {screen, look trough the left side}
\cdef      ScrTR    {} \CIRCcioptic  82
%<+doc> {screen, look trough the right side}
\cdef      Laser    {} \CIRCcioptic 160
%<+doc> {laser}
\cdef      PM       {} \CIRCcioptic 162
%<+doc> {photometer, -multiplyer, etc.}
\bbdefNeTii  OM          \CIRCcioptic 164  {}
%<+doc> {optical modulator}
%</optics,doc>
%<*optics>
\protectcirc
%    \end{macrocode}
%</optics>
%^^A last update: Fri  03-13-1998
%<*ciphysic>
\freecirc
\addCIRCfont ciphysic
%</ciphysic>
%<+doc>\optionline physics
%<*ciphysic,doc>
\cdef spring k \CIRCciphysic 0
%<+doc> {spring}
\cdef lspring k \CIRCciphysic 2
%<+doc> {long spring}
\cdef fdmass m \CIRCciphysic 4
%<+doc> {mass with two forces; full drawn}
\cdef dmass m \CIRCciphysic 6
%<+doc> {mass with two forces; outlined}
\cdefiv fmass m \CIRCciphysic 8 . *
%<+doc> {mass; full drawn}
\cdefiv mass m \CIRCciphysic 12 . *
%<+doc> {mass; outlined}
\cdefivNL wall \CIRCciphysic 16 . |
%<+doc> {wall}
\cdefivNL tile \CIRCciphysic 20 . *
%<+doc> {tile}
\cdef spinu S \CIRCciphysic 24
%<+doc> {spin up}
\cdef spind S \CIRCciphysic 26
%<+doc> {spin down}
%</ciphysic,doc>
%<*ciphysic>
\protectcirc
%</ciphysic>
%^^A last update: Fri  03-13-1998
%<*doc>
\protectcirc
%    \end{macrocode}
%</doc>
%<*code>
%^^A last update: Fri  03-13-1998
%
%    \begin{macrocode}
\def\line*r{\check*X\ifnum\cnta*=0\else\check*max{\dimen2}\ifxoutofgrid
  \advance\dimen2-.5\fontdimen6\c*fnt\fi
  \setbox\*bbox=\hbox{\ifxoutofgrid\else\char\cc*\fi\advance\cc*1%
                      \loop\ifnum\cnta*>1\char\cc*
                      \advance\cnta*-1\repeat}\put*box
  \advance\*X*.5\dimen2\the\toks2\advance\*X*.5\dimen2
  \advance\cc*2\setbox\*bbox=\hbox{\char\cc*}\put*box\xoutofgridfalse\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\line*l{\advance\*X*-\dimen2
            \ifxoutofgrid\advance\*X*.5\fontdimen6\c*fnt\fi
            \**X\*X*\line*r\*X*\**X}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\line*u{\check*X\ifnum\cnta*=0\else\advance\cc*4\ifyoutofgrid
  \advance\dimen2-.5\fontdimen6\c*fnt\fi
  \setbox\box*=\hbox{\char\cc*}\advance\cc*-1%
  \setbox\*bbox=\vbox{\loop\ifnum\cnta*>1\copy\box*
                      \advance\cnta*-1\repeat
                      \ifyoutofgrid\else\hbox{\char\cc*}\fi}\put*box
  \advance\*Y*.5\dimen2\the\toks4\advance\*Y*.5\dimen2
  \advance\cc*2\setbox\*bbox=\vbox{\hbox{\char\cc*}}\put*box\youtofgridfalse\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\line*d{\advance\*Y*-\dimen2
            \ifyoutofgrid\advance\*Y*.5\fontdimen6\c*fnt\fi
            \**Y\*Y*\line*u\*Y*\**Y}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\test*xygrid{\dimen9\fontdimen6\c*fnt\count@\dimen9
                \cntb*\*X*\divide\cntb*\count@
                \dimen0\*X*\advance\dimen0-\cntb*\dimen9
                \advance\dimen9-.1pt
                \ifdim\dimen0<0pt \dimen0-\dimen0 \fi
                \ifdim\dimen0>0.1pt \ifdim\dimen0<\dimen9 \xoutofgridtrue\fi\fi
                \cntb*\*Y*\divide\cntb*\count@
                \dimen0\*Y*\advance\dimen0-\cntb*\fontdimen6\c*fnt
                \ifdim\dimen0<0pt \dimen0-\dimen0 \fi
                \ifdim\dimen0>0.1pt \ifdim\dimen0<\dimen9 \youtofgridtrue\fi\fi}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\bundle#1 #2 #3 {\cc*136\c*fnt\cnta*#2\dimen2=#2em
                     \toks2{\setbox\box*=\hbox{\char134}%
                     \setbox\*bbox=\rlap{\raise\ht\box*
                     \hc*{\labelfont#1}\unhbox\box*}\put*box}%
                     \toks4{\setbox\*bbox=\hbox{\char135\labelfont
                     \vc*{\hbox{#1}}}%
                     \check*max{\wd\*bbox}\put*box}%
                     \test*xygrid\csname line*#3\endcsname}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\wwire#1 #2 #3 {\cc*112\c*fnt\cnta*#2\dimen2=#2em
                    \toks2{\setbox\*bbox=\rlap{\raise\*spc
                    \hc*{\labelfont#1}}\put*box}%
                    \toks4{\setbox\*bbox=\hbox{\kern\*spc\labelfont
                    \vc*{\hbox{#1}}}%
                    \check*max{\wd\*bbox}\put*box}%
                    \test*xygrid\csname line*#3\endcsname}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\by#1 {\def\by*cmd{#1}}
\by{\wire}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\calc*u{\cnta*\fontdimen6\c*fnt\advance\dimen0 .5\fontdimen6\c*fnt
            \cntb*\dimen0\divide\cntb*\cnta*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\vtopin#1 {\save*XY\frompin{#1} \test*xygrid
               \dimen0\**Y\advance\dimen0-\*Y*\restore*XY
               \ifdim\dimen0<0pt\dimen0-\dimen0
               \calc*u\by*cmd {\cntb*} u
               \else\calc*u\by*cmd {\cntb*} d \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\htopin#1 {\save*XY\frompin{#1} \test*xygrid
               \dimen0\**X\advance\dimen0-\*X*\restore*XY
               \ifdim\dimen0<0pt\dimen0-\dimen0
               \calc*u\by*cmd {\cntb*} r
               \else\calc*u\by*cmd {\cntb*} l \fi}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\safedef{Utext}#1 from #2 to #3 {{%
  \frompin{#2} \save*XY\frompin{#3} \diff*XY
    \ifdim\**X=0pt
      \setbox1=\hbox{\c*fnt\char132}%
      \ifdim\**Y<0pt
        \dimen0-\**Y
        \setbox0=\hbox{\c*fnt\char'373}\advance\dimen0-\ht0\dp0=0pt
        \calc*u
        \setbox\*bbox=
          \vtop to -\**Y{\vfill\box0\loop\ifnum\cntb*>2\copy1
            \advance\cntb*-1\repeat\vfill}%
      \else
        \dimen0\**Y
        \setbox0=\hbox{\c*fnt\char'371}\advance\dimen0-\ht0\dp0=0pt
        \calc*u
        \setbox\*bbox=
          \vbox to \**Y{\vfill\loop\ifnum\cntb*>2\copy1
            \advance\cntb*-1\repeat\box0\vfill}%
      \fi
      \put*box\advance\*X*\*spc\advance\*Y*.5\**Y\put\vc*{\hbox{#1}}
    \else
    \ifdim\**Y=0pt
      \ifdim\**X<0pt
        \dimen0-\**X
        \setbox0=\hbox{\c*fnt\char'372}\advance\dimen0-\wd0
        \calc*u
        \setbox\*bbox=\llap{\hbox to -\**X{\hfill\loop\ifnum\cntb*>2\char129
          \advance\cntb*-1\repeat\box0\hfill}}%
      \else
        \dimen0\**X
        \setbox0=\hbox{\c*fnt\char'370}\advance\dimen0-\wd0
        \calc*u
        \setbox\*bbox=\hbox to \**X{\hfill\box0\loop\ifnum\cntb*>2\char129
          \advance\cntb*-1\repeat\hfill}%
      \fi
      \put*box\advance\*X*.5\**X\advance\*Y*\*spc\put\hc*{#1}
    \else\errhelp{Only horizontal or vertical labeling allowed.}%
    \errmessage{Bad points!}\fi\fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\safedef{centertext}#1 from #2 to #3 {%
  {\frompin{#2} \save*XY\frompin{#3} \diff*XY
    \ifdim\**X=0pt
      \advance\*Y*.5\**Y\put\vc*{\hbox{#1}}
    \else
    \ifdim\**Y=0pt
      \advance\*X*.5\**X\put\hc*{#1}
    \else\errhelp{Only horizontal or vertical labeling allowed.}%
    \errmessage{Bad points}\fi\fi}}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
% Die absolute Positionierung in einem Raster von 7\,pt wird durch
% das direkte Setzen der aktuellen Zeichenposition realisiert.
% Die x-, und y-Position bezieht sich dabei auf den Punkt der
% ersten Zeichenoperation, dem die Werte $(0,0)$ zugeordnet wurden.
%    \begin{macrocode}
\def\from#1 #2 {\c*fnt\*X*=#1em\*Y*=#2em\check*X}
\let\at\from
%    \end{macrocode}
%
%    \begin{macrocode}
\def\moverel#1 #2 {\c*fnt\advance\*X* #1em\advance\*Y* #2em\check*X}
\let\shift\moverel
%    \begin{macrocode}
%
%    \begin{macrocode}
\safedef{put}#1 {\setbox\*bbox=\hbox{\ctextfont#1}\check*X
                 \check*max{\wd\*bbox}\put*box}

%    \end{macrocode}
\safedef{P}#1 {\store*XY{P#1}\check*X\reset*ifs}
%
\safedefs{_} #1 #2 {\c*fnt\cnta*=0\csname CiRC#2\endcsname\relax
               \ifnum\cnta*=0\relax
               \PackageError{CIRC}{Bad direction}{Please check spelling}\fi
               \ifcase \cnta* \relax
               \or \advance\*X* -#1em
               \or \advance\*X*  #1em
               \or \advance\*Y*  #1em
               \or \advance\*Y* -#1em
               \or \advance\*X* -#1em
               \or \advance\*X*  #1em
               \or \advance\*Y*  #1em
               \or \advance\*Y* -#1em \fi}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\nl{\lab*false}
\def\nv{\val*false}
\def\cc{\cc*true}
\def\clr*acmds{\global\let\add*cmds\relax}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%    \begin{macrocode}
\def\*fdef#1 {\expandafter\xdef\csname#1\endcsname{\the\toks0}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newtoks\CIRCfinit
\CIRCfinit={}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\addCIRCfont#1 {\expandafter\CIRCfinit=\expandafter{\the\CIRCfinit
                    \expandafter\font\csname CIRC#1\endcsname=#1 scaled \*mag}}
%    \end{macrocode}
%    \begin{macrocode}
\def\CIusefont#1#2#3{\fontencoding{\encodingdefault}\fontfamily{#1}%
                     \fontseries{\seriesdefault}\fontshape{\shapedefault}%
                     \fontsize{#2}{#3}\selectfont}
\def\circuit#1 {\PackageInfo{CIRC}{`\CIRCredef' redefined}%
    \let\add*cmds\relax
    \*Ilist{}\*Olist{}\check*true
    \xdef\*mag{\magstep{#1}}%
    \global\X*max-\maxdimen
    \global\X*min\maxdimen
\ifcase#1 % magstep 0
    \toks0={\CIusefont{\rmdefault}{10}{12pt}}%
    \*fdef outlabelfont
    \*fdef labelfont
    \*fdef ctextfont
    \toks0={\CIusefont{\sfdefault}{10}{12pt}}%
    \*fdef symfont
    \toks0={\CIusefont{\rmdefault}{7}{8pt}}%
    \*fdef pinnumberfont
    \*fdef functionfont
    \toks0={\CIusefont{\rmdefault}{8}{9.5pt}}%
    \*fdef circlabelfont
    \toks0={\CIusefont{\sfdefault}{8}{9.5pt}}%
    \*fdef inlabelfont
\or       % magstep 1
    \toks0={\CIusefont{\rmdefault}{12}{14pt}}%
    \*fdef outlabelfont
    \*fdef labelfont
    \*fdef ctextfont
    \toks0={\CIusefont{\sfdefault}{12}{14pt}}%
    \*fdef symfont
    \toks0={\CIusefont{\rmdefault}{8}{9.5pt}}%
    \*fdef pinnumberfont
    \toks0={\CIusefont{\rmdefault}{9}{11pt}}%
    \*fdef functionfont
    \*fdef circlabelfont
    \toks0={\CIusefont{\sfdefault}{9}{11pt}}%
    \*fdef inlabelfont
\or       % magstep 2
    \toks0={\CIusefont{\rmdefault}{14.4}{18pt}}%
    \*fdef outlabelfont
    \*fdef labelfont
    \*fdef ctextfont
    \toks0={\CIusefont{\sfdefault}{14.4}{18pt}}%
    \*fdef symfont
    \toks0={\CIusefont{\rmdefault}{9}{11pt}}%
    \*fdef pinnumberfont
    \toks0={\CIusefont{\rmdefault}{10}{12pt}}%
    \*fdef functionfont
    \*fdef circlabelfont
    \toks0={\CIusefont{\sfdefault}{10}{12pt}}%
    \*fdef inlabelfont
\or       % magstep 3
    \toks0={\CIusefont{\rmdefault}{17.28}{22pt}}%
    \*fdef outlabelfont
    \*fdef labelfont
    \*fdef ctextfont
    \toks0={\CIusefont{\sfdefault}{17.28}{22pt}}%
    \*fdef symfont
    \toks0={\CIusefont{\sfdefault}{10}{12pt}}%
    \*fdef pinnumberfont
    \toks0={\CIusefont{\rmdefault}{12}{14pt}}%
    \*fdef functionfont
    \*fdef circlabelfont
    \toks0={\CIusefont{\sfdefault}{12}{14pt}}%
    \*fdef inlabelfont
\or       % magstep 4
    \toks0={\CIusefont{\rmdefault}{20.74}{25pt}}%
    \*fdef outlabelfont
    \*fdef labelfont
    \*fdef ctextfont
    \toks0={\CIusefont{\sfdefault}{20.74}{25pt}}%
    \*fdef symfont
    \toks0={\CIusefont{\rmdefault}{12}{14pt}}%
    \*fdef pinnumberfont
    \toks0={\CIusefont{\rmdefault}{14.4}{18pt}}%
    \*fdef functionfont
    \*fdef circlabelfont
    \toks0={\CIusefont{\sfdefault}{14.4}{18pt}}%
    \*fdef inlabelfont
\else\errhelp{0 ... 4 expected.}\errmessage{Bad magnification!}\fi
%
{\outlabelfont
\global\*spc 0.4em}%
%
\font\c*fnt=cirest      scaled \*mag
\font\c*fntb=cicirc     scaled \*mag
\font\c*fntd=cidiod     scaled \*mag
\font\c*fntt=cibimos    scaled \*mag
\font\c*fntw=ciwidko    scaled \*mag
\font\c*fnts=cisym      scaled \*mag
%
\outerspace1mm
\pinnum*spc.7mm
\pin*ind\fontdimen12\c*fntb
\pin*spc\fontdimen13\c*fntb
\io*ind\fontdimen14\c*fntb
\mid*ind\fontdimen16\c*fntb
\X*min\maxdimen
\X*max-\maxdimen
%
\the\CIRCfinit
\begingroup
%
  \the\rmacros
  \let\.\junction
  \def\- ##1 ##2 {\wire##1 ##2 }%
  \def\= ##1 ##2 ##3 {\bundle##1 ##2 ##3 }%
  \def\<{\ld*true}%
%
\parindent0pt
\offinterlineskip\setbox\*bbox=\hbox\bgroup\at 0 0 }
%    \end{macrocode}
%
%    \begin{macrocode}
\def\endcircuit{\egroup\leavevmode
                \hbox{\kern-\X*min\unhbox\*bbox\kern\X*max}\endgroup
                \PackageInfo{CIRC}{`\CIRCredef' restored}}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
%
\safedef{fallingEdge}{{\c*fnts\char3}}
\safedef{raisingEdge}{{\c*fnts\char2}}
\safedef{spike}{{\c*fnts\char4}}
\safedef{ispike}{{\c*fnts\char12}}
\safedef{squarePulse}{{\c*fnts\char1}}
\safedef{squarePulses}{{\c*fnts\char5}}
\safedef{sawtoothPuls}{{\c*fnt\char6}}
%
%^^A last update: Fri  03-13-1998
% The last thing we define is the logo of CIRC.
% This pretty small grey elephant was choosen and then digitized as a
% result of a discussion about the incomming of new symbols into
% CIRC. Idea by Andreas Tille.
%    \begin{macrocode}
\def\CIRCLogo{\c*fnt\cc*0\getc*252 \check*max{.5\wd*}\check*min{.5\wd*}%
  \setbox\*bbox=\hbox to \wd*{\hss\lower\ht*\hbox to 0pt{\hss
  \symfont\raise1.5ex\rlap{\kern1ex CIRC}\box\box*}\hss}\put*box\reset*ifs}
%    \end{macrocode}
%^^A last update: Fri  03-13-1998
% Alle internen Buchstaben werden wieder auf ihren vormaligen
% Kategoriekode gesetzt.
%    \begin{macrocode}
\protectcirc
%    \end{macrocode}
% Now we are ready to process all options of CIRC.
% That means to load all modules.
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
%</code>
%^^A last update: Fri  03-13-1998
%<*ic>
%    \begin{macrocode}
\ProvidesFile{ic.def}
%    \end{macrocode}
%    \begin{macrocode}
\freecirc
%    \end{macrocode}
%
%    \begin{macrocode}
\def\**[#1 #2 #3 #4 {\cc*\cnta*\advance\cc*32 \advance\cc*#1
  \Cstore*\*Ilist{#2}\Cadd*\*Ilist
  \rlap{\kern\pin*ind\ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#3}}\fi
  \kern\io*ind\c*fntb\vc*{\hc*{\inlabelfont{#4}}}}\char\cc*
  \cc*\cnta*\advance\cc*97\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\**]#1 #2 #3 #4 {\cc*\cnta*\advance\cc*48 \advance\cc*#1
  \Cstore*\*Olist{#2}\Cadd*\*Olist
  \rlap{\kern.5\mid*ind\vc*{\hc*{\inlabelfont{#3}}}\kern\io*ind
  \ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#4}}\fi}\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*F[#1 #2 #3 #4 #5 {\cc*\cnta*\advance\cc*#1
  \X*check\Cstore*\*Ilist{#2}\Cadd*\*Ilist
  \rlap{\kern\pin*ind\ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#3}}\fi
  \kern\io*ind\c*fntb\vc*{\hc*{\inlabelfont{#4}}}}%
  \rlap{\kern\io*ind\kern\mid*ind
  \blap{\kern0pt\hc*{\functionfont{#5}}}}\char\cc*
  \cc*\cnta*\advance\cc*96\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*F]#1 #2 #3 #4 {\cc*\cnta*\advance\cc*16 \advance\cc*#1
  \LX*check\*Olist\Cstore*\*Olist{#2}\Cadd*\*Olist
  \rlap{\kern.5\mid*ind\vc*{\hc*{\inlabelfont{#3}}}\kern\io*ind
  \ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#4}}\fi}\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*L[#1 #2 #3 #4 #5 {\cc*\cnta*\advance\cc*64 \advance\cc*#1
  \Cstore*\*Ilist{#2}\Cadd*\*Ilist
  \rlap{\kern\pin*ind\ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#3}}\fi
  \kern\io*ind\c*fntb\vc*{\hc*{\inlabelfont{#4}}}}%
  \rlap{\iflab*\kern\io*ind\kern\mid*ind
  \vtop{\kern\fontdimen17\c*fntb\kern\outerspace
  \hc*{\circlabelfont{#5}}}\fi}\char\cc*
  \cc*\cnta*\advance\cc*98\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*L]#1 #2 #3 #4 {\cc*\cnta*\advance\cc*80 \advance\cc*#1
  \Cstore*\*Olist{#2}\Cadd*\*Olist
  \rlap{\kern.5\mid*ind\vc*{\hc*{\inlabelfont{#3}}}\kern\io*ind
  \ifpin\raise\pinnum*spc\hc*{\pinnumberfont{#4}}\fi}\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*H#1 {\cc*\cnta*\X*check\Cadd*\*Ilist
 \rlap{\kern\io*ind\kern\mid*ind\blap{\kern-\*spc\labelfont\hc*{#1\ }}}%
  \char\cc*\cc*\cnta*\advance\cc*96\char\cc*\cc*\cnta*\advance\cc*16
  \LX*check\*Olist\Cadd*\*Olist\char\cc*}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\C*init{\dimen4\*X*\dimen5\*Y*
  \setbox\*bbox=\vtop\bgroup\c*fntb\cnta*=0 \ignorespaces}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\C*exit#1{\egroup\shift*IOlist{#1}\put*box\*X*\dimen4\*Y*\dimen5}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*o#1{$\overline{\hbox{#1}}$}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\*|#1| {\hbox{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\JKMSFF#1 #2 #3 #4 {\name*{JKMSFF#1}\C*init
\*|\*F[2  S   {}   S   {}     \*F]0  .  {}      {} |
\*|\**[1  J   {}   1J         \**]1  Q  $\neg$  {} |
\*|\**[3  C   {}   C1         \**]0  .  {}      {} |
\*|\**[1  K   {}   1K         \**]2  NQ $\neg$  {} |
\*|\*L[2  R   {}   R   {#2}   \*L]0  .  {}      {} |
\C*exit{#3}}
%    \end{macrocode}
%    \begin{macrocode}
\def\DFF#1 #2 #3 #4 {\name*{DFF#1}\C*init
\*|\*F[1  D   {}   1D  {}     \*F]1  Q  {}      {} |
\*|\**[0  .   {}   {}         \**]0  .  {}      {} |
\*|\*L[3  C   {}   C1  {#2}   \*L]2  NQ {}      {} |
\C*exit{#3}}
%    \end{macrocode}
%    \begin{macrocode}
\def\RSFF#1 #2 #3 #4 {\name*{RSFF#1}\C*init
\*|\*F[1  R   {}   R   {}     \*F]1  Q  {}      {} |
\*|\**[0  .   {}   {}         \**]0  .  {}      {} |
\*|\*L[1  S   {}   S  {#2}    \*L]2  NQ {}      {} |
\C*exit{#3}}
%    \end{macrocode}
%    \begin{macrocode}
\def\NRSFF#1 #2 #3 #4 {\name*{NRSFF#1}\C*init
\*|\*F[2  R   {}   R   {}     \*F]1  Q  {}      {} |
\*|\**[0  .   {}   {}         \**]0  .  {}      {} |
\*|\*L[2  S   {}   S  {#2}    \*L]2  NQ {}      {} |
\C*exit{#3}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\fff#1 #2 #3 #4 {\name*{fff#1}\C*init
\*|\*F[1  IS  {6}  IS   {         }     \*F]1  OK  OK 5  |
\*|\**[0  .   {}   {}                   \**]0  .   {} {} |
\*|\**[1  IT  {2}  IT                   \**]1  O   O  3  |
\*|\**[0  .   {}   {}                   \**]0  .   {} {} |
\*|\*L[2  R   {4}  R    {#2}            \*L]1  OD  OD 7  |
\C*exit{#3}}
%    \end{macrocode}
%    \begin{macrocode}
\def\NULL#1 #2 #3 #4 {\name*{NULL#1}\C*init
\*|\*H{$\vcenter{\hbox{\c*fnts\char25}}\ \infty$} |
\*|\**[1  i+  {}  +             \**]1  o+ +  {} |
\*|\**[0  .   {}  {}            \**]0  .  {} {} |
\*|\*L[1  i-  {}  $-$  {#2}     \*L]1  o- $-$  {} |
\C*exit{#3}}
%    \end{macrocode}
%    \begin{macrocode}
\protectcirc
%    \end{macrocode}
%</ic>
%^^A last update: Fri  03-13-1998
%<*ciphysicmf>
font_identifier:="ciphysic";

string optionname; optionname:="physics";

input defcirc.mf;


%% SPRING

spring_lt#= 5CIu#;
lspring_lt#= 7CIu#;
spring_th#= 1CIu#;
define_whole_pixels(lspring_lt,spring_lt,spring_th);
spring_gap= .6CIu;
spring_n=11;
spring_swd=(spring_lt-2spring_gap)/spring_n;
lspring_swd=(lspring_lt-2spring_gap)/spring_n;

twopinchar("spring")("k")("spring")
  (spring_lt#, .5spring_th#, .5spring_th#)
( pickup pensquare scaled normalline;
  z0=(0,0);
  shiftpoint:=z0+(spring_lt,0);
  z1=z0+(spring_gap,0);
  draw z0--z1;
  pickup pencircle scaled normalline;
  for i:=1 upto spring_n:
    x[i+1]=x[i]+spring_swd; y[i+1]=y[0]+if odd(i): 1 else: -1 fi*.5spring_th;
    if i=spring_n: y[i+1]:=y[i+1]-if odd(i): 1 else: -1 fi*.5spring_th fi;
    draw z[i]--z[i+1];
  endfor;
  z[spring_n+2]=z0+(spring_lt,0);
  pickup pensquare scaled normalline;
  z[spring_n+2]=z0+(spring_lt,0);
  draw z[spring_n+1]--z[spring_n+2];
)

twopinchar("lspring")("k")("long spring")
  (lspring_lt#, .5spring_th#, .5spring_th#)
( pickup pensquare scaled normalline;
  z0=(0,0);
  shiftpoint:=z0+(lspring_lt,0);
  z1=z0+(spring_gap,0);
  draw z0--z1;
  pickup pencircle scaled normalline;
  for i:=1 upto spring_n:
    x[i+1]=x[i]+lspring_swd; y[i+1]=y[0]+if odd(i): 1 else: -1 fi*.5spring_th;
    if i=spring_n: y[i+1]:=y[i+1]-if odd(i): 1 else: -1 fi*.5spring_th fi;
    draw z[i]--z[i+1];
  endfor;
  z[spring_n+2]=z0+(lspring_lt,0);
  pickup pensquare scaled normalline;
  draw z[spring_n+1]--z[spring_n+2];
)

%% MASS single/double

dmass_lt#= 2CIu#;
mass_r#=  1.5CIu#;
define_whole_pixels(dmass_lt,mass_r);

twopinchar("fdmass")("m")("mass with two forces; full drawn")
  (dmass_lt#, .5mass_r#, .5mass_r#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(dmass_lt,0);
   shiftpoint:=z1;
   draw z0--z1;
   z2=.5[z0,z1];
   pickup pencircle scaled mass_r;
   drawdot z2;
)

twopinchar("dmass")("m")("mass with two forces; outlined")
  (dmass_lt#, .5mass_r#, .5mass_r#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(.5(dmass_lt-mass_r),0);
   draw z0--z1;
   z3=z0+(dmass_lt,0);
   shiftpoint:=z3;
   z4=z3-(.5(dmass_lt-mass_r),0);
   draw z3--z4;
   z2=.5[z0,z3];
   pickup pencircle scaled normalline;
   draw fullcircle scaled mass_r shifted z2;
)

twopincharfour("fmass")("m")(".")("*")("mass; full drawn")
  (dmass_lt#, .5mass_r#, .5mass_r#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(dmass_lt,0);
   z2=.5[z0,z1];
   draw z0--z2;
   pickup pencircle scaled mass_r;
   drawdot z2;

   shiftpoint:=z1;
)

twopincharfour("mass")("m")(".")("*")("mass; outlined")
  (dmass_lt#, .5mass_r#, .5mass_r#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(.5(dmass_lt-mass_r),0);
   draw z0--z1;
   z3=z0+(dmass_lt,0);
   z2=.5[z0,z3];
   pickup pencircle scaled normalline;
   draw fullcircle scaled mass_r shifted z2;

   shiftpoint:=z3;
)

%% WALL

wall_lt#= 1.5CIu#;
wall_ht#= 2.5CIu#;
define_whole_pixels(wall_ht, wall_lt);
wall_f=1/3;
wall_n=6;
wall_alpha=40;

twopincharfour("wall")("{}")(".")("|")("wall")
  (wall_lt#,.5wall_ht#
               +wall_lt#*(1-wall_f)*sind(wall_alpha),.5wall_ht#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(wall_f*wall_lt,0);
   draw z0--z1;
   z1=.5[z2,z3]; y3-y2=wall_ht; x3=x2;
   pickup pensquare scaled verythickline;
   draw z2--z3;
   path a;
   a=(0,0)--(1-wall_f)*wall_lt*dir(wall_alpha);
   pickup pencircle scaled normalline;
   for i:=0 upto wall_n: draw a shifted (i/wall_n)[z2,z3]; endfor

   shiftpoint:=z0+(wall_lt,0);
)

tile_lt#= 2CIu#;
tile_ht#= .4CIu#;
tile_f=0.1;

define_whole_pixels(tile_lt,tile_ht);

twopincharfour("tile")("{}")(".")("*")("tile")
  (wall_lt#,.5tile_ht#,.5tile_ht#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(tile_lt,0);
   z2=tile_f[z0,z1];
   draw z0--z1;
   pickup pensquare scaled verythickline;
   draw z1--z2;
   shiftpoint:=z1;
)

spin_lt#= 2CIu#;
spin_r#=  .7CIu#;
spin_ht#= 2CIu#;
spin_alt= .5CIu;
spin_awd= .1CIu;
define_whole_pixels(spin_lt,spin_r, spin_ht);

twopinchar("spinu")("S")("spin up")
  (spin_lt#, .6spin_ht#, .6spin_ht#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(spin_lt,0);
   draw z0--z1;
   z2=.5[z0,z1];
   y3-y4=spin_ht;
   x3=x4=x2;
   y2=.6[y3,y4];
   y5=y6=y3-spin_alt;
   x5=x2-spin_awd;
   x6=x2+spin_awd;
%   pickup pencircle scaled thinline;
   draw z3--z4;
   filldraw z5--z3--z6--cycle;
   pickup pencircle scaled spin_r;
   drawdot z2;
   shiftpoint:=z1;
)

twopinchar("spind")("S")("spin down")
  (spin_lt#, .6spin_ht#, .6spin_ht#)
(  pickup pensquare scaled normalline;
   z0=(0,0);
   z1=z0+(spin_lt,0);
   draw z0--z1;
   z2=.5[z0,z1];
   y3-y4=-spin_ht;
   x3=x4=x2;
   y2=.6[y3,y4];
   y5=y6=y3+spin_alt;
   x5=x2-spin_awd;
   x6=x2+spin_awd;
%   pickup pencircle scaled thinline;
   draw z3--z4;
   filldraw z5--z3--z6--cycle;
   pickup pencircle scaled spin_r;
   drawdot z2;
   shiftpoint:=z1;
)

endCIRCfont
%</ciphysicmf>
%^^A last update: Fri  03-13-1998
%
%<*csybimos>
font_identifier:="cibimos";

string optionname; optionname:="";

input defcirc.mf;

input csym;
designsize:=1lLE#;

def mosfet =  % ok
  z0=(0,0);
  x1=x2=x3=x4;
  y2-y1=mos_SD;
  y4-y3=mos_sd;
  .5[z2,z1]=.5[z4,z3];
  y6=y4; y7=y3;
  x4-x6=x3-x7;
  .5[z8,z9]=.5[z6,z7]=z5;
  x9=x8;
  y8-y6=mos_soSD;
  x10=x11;
  x0+mos_Gsub=x10+mos_ox=x7;
  x1-x0=mos_GSx;
  y0=y10=y1+mos_GSy;
  y6-y11=y10-y7;
  z12=.5[z1,z2];
  z6=.5[z13,z8];
  z7=.5[z14,z9];
  z15-z16=z8-z13;
  z5=.5[z15,z16];
  pickup pencircle scaled mos_rad;
  drawdot round(z3);
  pickup pensquare scaled normalline;
  draw z1--z3--z7;
  draw z2--z4--z6;
  draw z0--z10--z11;
  draw z5--z12--z3;
  pickup pensquare scaled thickline;
enddef;

def mosfet_V =  % ok
  mosfet;
  draw z8--z9;
enddef;

def mosfet_A =  % ok
  mosfet;
  draw z8--z13;
  draw z9--z14;
  draw z15--z16;
enddef;

def fet =  % ok
    z0=(0,0);
    z1=z0+(fet_Gsub,0);
    y2=y1;
    x2=x3=x4=x0+fet_GSx;
    y3=y2-fet_GSy;
    z2-z3=z4-z5;
    y4-y3=fet_SD;
    y6=y5;
    x1=x6;
    x8=x7;
    y8=y1-fet_soSD;
    .5[z4,z3]=.5[z5,z2];
    .5[z7,z8]=.5[z1,z6];
    z9=z1-(fet_sarr+tri_lt,0);
    pickup pensquare scaled normalline;
    draw z0--z1--z2--z3;
    draw z6--z5--z4;
    pickup pensquare scaled thickline;
    draw z7--z8;
enddef;

def transistor_without_basis =  % "uberarbeiten
  numeric pl;
  pl:=.5(tst_ht-tst_iht);
  z1-z2=(0,tst_iht);
  z0=.5[z1,z2];
  z3=tst_fac[z0,z1];
  z4=tst_fac[z0,z2];
  z5=z1+(tst_wd,0);
  z6=z2+(tst_wd,0);
  z7=z5+(0,pl);
  z8=z6+(0,-pl);
  z9=tst_dis[z4,z6];
  pickup pensquare scaled normalline;
  draw z1--z2;
  draw z3--z5--z7;
  draw z4--z6--z8;
  pickup pencircle scaled thinline;
  triangle(z9,tst_rad,tri_phi,angle(z6-z4));
enddef;

def npn_no_basis =  % "uberarbeiten
  numeric tst_rad,tst_dis;
  tst_rad:=-tri_lt;
  tst_dis:=npn_dis;
  z0=(0,0);
  transistor_without_basis;
enddef;

def npn_photo =  % "uberarbeiten
numeric pl;
  z0=(0,0);
  pl:=.5(tst_ht-tst_iht);
  y0=y1=y2=y3;
  x1=x0+tst_ht;
  x2-x0=x1-x3=pl;
  y5=y4=y6=y7=y8=y0+tst_wd;
  x5-x6=tst_iht;
  x4=.5[x5,x6]=.5[x0,x1];
  x7=tst_fac[x4,x5];
  x8=tst_fac[x4,x6];
  z9=tst_dis[z2,z8];
  pickup pensquare scaled normalline;
  draw z0--z2--z8--z7--z3--z1;
  draw z5--z6;
  pickup pencircle scaled thinline;
  triangle(z9,tst_rad,tri_phi,angle(z8-z2));
enddef;

def pnp_no_basis =  % "uberarbeiten
  numeric tst_rad,tst_dis;
  tst_rad:=tri_lt;
  tst_dis:=pnp_dis;
  z0=(0,0);
  transistor_without_basis;
enddef;

def npn =  % "uberarbeiten
  numeric tst_rad,tst_dis;
  tst_rad:=-tri_lt;
  tst_dis:=npn_dis;
  z0=(tst_wd,0);
  z20=(0,0);
  transistor_without_basis;
  pickup pensquare scaled normalline;
  draw z20--z0;
enddef;

def pnp =  % "uberarbeiten
  numeric tst_rad,tst_dis;
  tst_rad:=tri_lt;
  tst_dis:=pnp_dis;
  z0=(tst_wd,0);
  z20=(0,0);
  transistor_without_basis;
  pickup pensquare scaled normalline;
  draw z20--z0;
enddef;


"Transistor NPN ohne Basis";
eightchars(0)
   (npn_no_basis)
   (tst_wd#,.5tst_ht#,.5tst_ht#,0);

"Transistor PNP ohne Basis";
eightchars(8)
   (pnp_no_basis)
   (tst_wd#,.5tst_ht#,.5tst_ht#,0);

"Transistor NPN";
eightchars(16)
   (npn)
   (tst_wd#+tst_wd#,.5tst_ht#,.5tst_ht#,0);

"Transistor PNP";
eightchars(24)
   (pnp)
   (tst_wd#+tst_wd#,.5tst_ht#,.5tst_ht#,0);

"FET n-Kanal";
eightchars(32)
   (fet;
    pickup pencircle scaled thinline;
    triangle(z1,tri_lt,tri_phi,180);
   )
   (fet_GSx#,fet_GSy#,fet_SD#-fet_GSy#,0);

"FET p-Kanal";
eightchars(40)
   (fet;
    pickup pencircle scaled thinline;
    triangle(z9,tri_lt,tri_phi,0);
   )
   (fet_GSx#,fet_GSy#,fet_SD#-fet_GSy#,0);

"MOSFET n-Kanal V";
eightchars(48)
   (mosfet_V;
    pickup pencircle scaled thinline;
    triangle(z5,tri_lt,tri_phi,0);
   )
   (mos_GSx#,mos_GSy#,mos_SD#-mos_GSy#,0);

"MOSFET p-Kanal V";
eightchars(56)
   (mosfet_V;
    pickup pencircle scaled thinline;
    triangle(z12,tri_lt,tri_phi,180);
   )
   (mos_GSx#,mos_GSy#,mos_SD#-mos_GSy#,0);

"MOSFET n-Kanal A";
eightchars(64)
   (mosfet_A;
    pickup pencircle scaled thinline;
    triangle(z5,tri_lt,tri_phi,0);
   )
   (mos_GSx#,mos_GSy#,mos_SD#-mos_GSy#,0);

"MOSFET p-Kanal A";
eightchars(72)
   (mosfet_A;
    pickup pencircle scaled thinline;
    triangle(z12,tri_lt,tri_phi,180);
   )
   (mos_GSx#,mos_GSy#,mos_SD#-mos_GSy#,0);

current_char_code:=80;

twopincharfourfour("npnPH")("T")("E")("C")("photo transistor")
  (tst_ht#,tst_wd#+1.6lLE#,0)
(
shiftpoint:=z1;
npn_photo;
lightarrows(z4+(.8lLE,1.7lLE),240);
)

end;
%</csybimos>
%
%^^A last update: Fri  03-13-1998
%
%<*csysym>
input csym;
designsize:=.5lLE#;

def eqtriangle(expr l)=
  x1=x2=x0=x3-l;
  y3=y0;
  z1-z2=(z3-z2) rotated 60;
enddef;

def sinus(expr A, k, s) =
  j:=0;
  for i:=0 step s until 360:
    z[j]=(k*i,A*sind(i));
    j:=j+1;
  endfor
  draw for i:=0 upto floor(360/s)-1: z[i].. endfor z[floor(360/s)];
enddef;

def disarrow =
  z0=(0,0);
  x0=x1=x2;
  y1-y2=darr_ht;
  .5[z1,z2]=z0;
  y0=y3;
  x3-x0=darr_lt;
  pickup pensquare scaled normalline;
  draw z0--z3;
  draw z1--z2;
  triangle(z0,darr_rad,darr_phi,0);
enddef;

def trigger =
  z0=(0,0);
  x1=x2; x3=x4;
  y2=y4=y5; y0=y1=y3;
  x3-x1=.17sym;
  x1-x0=x5-x4=.3sym;
  y2-y1=sym;
enddef;

def impuls =
  z0=(0,0);
  y0=y1=y4=y5=y7=y8=y9;
  x1-x0=x3-x2=x5-x4=x8-x7=.6sym;
  x9-x0=x6-x2=.2sym;
  x1=x2; x3=x4;  x6=x7;
  y2-y1=y3-y4=y6-y7=sym;
  x10=x0; y11=y10=y2;
  x11=x8;
enddef;



 "Rechteckimpuls";
   beginchar(1,1.9sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw z0--z1--z2--z3--z4--z5;
   endchar;

 "positive Flanke";
   beginchar(2,1.3sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw z0--z1--z2--z3;
   endchar;

 "negative Flanke";
   beginchar(3,1.3sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw (z2--z3--z4--z5) shifted (x0-x1,0);
   endchar;

 "Nadelimpuls";
   beginchar(4,1.5sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw (z0--z1--z2--z6--z7--z8);
   endchar;

  "inverser Nadelimpuls";
   beginchar(12,1.5sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw (z10--z2--z1--z7--z6--z11);
   endchar;

 "Rechteckspannung";
   beginchar(5,3.1sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw z0--z1--z2--z3--z4--z5;
     draw (z0--z1--z2--z3--z4--z5) shifted z4;
   endchar;

 "Rechteckimpulse";
   beginchar(13,2.6sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw z0--z1--z2--z6--z7--z8;
     draw (z0--z1--z2--z6--z7--z8) shifted z4;

   endchar;

 "S"&ditto&"agezahn";
   beginchar(6,1.9sym#,sym#,0);
     impuls
     pickup pensquare scaled normalline;
     draw z0--z9--z3--z4--z5;
   endchar;

 "Trigger";
   beginchar(7,.87sym#,sym#,0);
     trigger
     pickup pensquare scaled normalline;
     draw z0--z1--z2--z5;
     draw z1--z3--z4;
   endchar;

 "Abstandsst"&ditto&"uck";
 fourchars(8)(disarrow)(z0)(.5darr_ht#,darr_lt#,.5darr_ht#);

"sinus wave";
beginchar(16,1.6sym#,9/35*sym#,9/35*sym#);
  pickup pencircle scaled normalline;
  sinus(9/35*sym,1.6sym/360,45);
endchar;

"variable sinus wave";
beginchar(17,1.6sym#,9/35*sym#,9/35*sym#);
  pickup pencircle scaled normalline;
  sinus(9/35*sym,1.6sym/360,45);
  fillarrow((.8*sym,0),20/35*sym,15/35*sym,45,15/35*sym,15)();
endchar;

"symbol of amplifier";
beginchar(24,cosd(30)*1.9sym#,.95sym#,.95sym#);
  z0=(0,0);
  eqtriangle(1.9sym);
  pickup pencircle scaled normalline;
  draw z1--z2--z3--cycle;
endchar;

"symbol of buffer";
beginchar(25,cosd(30)*1sym#,.5sym#,.5sym#);
  z0=(0,0);
  eqtriangle(1sym);
  pickup pencircle scaled normalline;
  draw z1--z2--z3--cycle;
endchar;

bye;
%</csysym>
%
%^^A last update: Fri  03-13-1998
%<*defcircmf>
mode_setup;
font_coding_scheme:="CIRC symbols";

message("CIRC %<*"&font_identifier_&">");
message("CIRC \freecirc");
message("CIRC \addCIRCfont "&font_identifier_);
message("CIRC %</"&font_identifier_&">");
message("CIRC %<+doc> \optionline "&optionname);
message("CIRC %<*"&font_identifier_&",doc>");
message("");

def endCIRCfont =
  message("CIRC %</"&font_identifier_&",doc>");
  message("CIRC %<*"&font_identifier_&">");
  message("CIRC \protectcirc");
  message("CIRC %</"&font_identifier_&">");
  message("");
  bye;
enddef;

CIu#:=7pt#; define_whole_pixels(CIu);
% define all symbols by a 7pt grid  --> CIRC unit

current_char_code:=0;
% start with character code 0

pair shiftpoint;

linethickness#:= 0.45pt#;
thinline#     := 0.5linethickness#;
normalline#   := 1.0linethickness#;
thickline#    := 1.5linethickness#;
verythickline#:= 2.5linethickness#;
define_whole_blacker_pixels(normalline,thinline,thickline,verythickline);

fontdimen6: 1CIu#;
%export the CIRC unit to TeX

extra_endchar:=extra_endchar & "labels(range 0 thru 100);";
% for proofing mark all points

def {{ =
   begingroup
   save T; transform T;
   T:=currenttransform;
   save currenttransform;
   transform currenttransform;
   currenttransform:=T;
enddef;

def }} = endgroup; enddef;

def addTF(text t) = currenttransform:=currenttransform t; enddef;

def twopinchar(text name, lab, doc)(expr wd, ht, dp)(text body) =
  message("CIRC \cdef "&name&" "&lab&" \CIRC"&
          font_identifier_&" "&decimal(current_char_code));
  message("CIRC %<+doc> {"&doc&"}");
  message("");
  beginchar(current_char_code, wd, ht, dp);
    body;
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,dp,wd,ht);
    {{addTF(shifted -shiftpoint rotated -90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
enddef;

def twopincharfour(text name, lab, pini, pinii, doc)
                  (expr wd, ht, dp)(text body) =
  message("CIRC \cdefiv "&name&" "&lab&" \CIRC"&
          font_identifier_&" "&decimal(current_char_code)&" "&
          pini&" "&pinii);
  message("CIRC %<+doc> {"&doc&"}");
  message("");
  beginchar(current_char_code,wd,ht,dp);
    body;
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,dp,wd,ht);
    {{addTF(rotated 90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,wd,dp,ht);
    {{addTF(shifted -shiftpoint rotated 180); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,ht,wd,dp);
    {{addTF(shifted -shiftpoint rotated -90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
enddef;

def twopincharfourfour(text name, lab, pini, pinii, doc)
                  (expr wd, ht, dp)(text body) =
  message("CIRC \cdefiviv "&name&" "&lab&" \CIRC"&
          font_identifier_&" "&decimal(current_char_code)&" "&
          pini&" "&pinii);
  message("CIRC %<+doc> {"&doc&"}");
  message("");
  beginchar(current_char_code,wd,ht,dp);
    body;
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,dp,wd,ht);
    {{addTF(rotated 90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,wd,dp,ht);
    {{addTF(shifted -shiftpoint rotated 180); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,ht,wd,dp);
    {{addTF(shifted -shiftpoint rotated -90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,wd,dp,ht);
    {{addTF(reflectedabout(left,right)); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,ht,wd,dp);
    {{addTF(reflectedabout(left,right) rotated 90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,wd,ht,dp);
    {{addTF(reflectedabout (left,right) shifted -shiftpoint rotated 180); body;}}
  endchar;
  current_char_code:=current_char_code+1;
  beginchar(current_char_code,dp,wd,ht);
    {{addTF(reflectedabout(left,right) shifted -shiftpoint rotated -90); body;}}
  endchar;
  current_char_code:=current_char_code+1;
enddef;
%</defcircmf>
%^^A last update: Sat  06-13-2003
%
%<*csywidko>
input csym;
designsize:=.5lLE#;

def resistor =
  numeric pl;
  pl:=.5(res_lt-res_wd);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(res_wd,0);
  z3=z2+(pl,0);
  z4-z5=z6-z7=(0,res_ht);
  z1=.5[z4,z5];
  z2=.5[z6,z7];
  z8=z0+(res_x,-res_y);
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z2--z3;
  draw z4--z6--z7--z5--cycle;
enddef;

usR_iwd# = 3lLE#;
usR_iht# = 1lLE#;
usR_wd# = 4lLE#;
usR_f   = .25;
define_pixels(usR_iwd, usR_iht, usR_wd);

vardef usR =
  z0=(0,0);
  z1=z0;
  y1=y2=y3=y4;
  x2-x1=usR_wd;
  x4-x3=usR_iwd;
  .5[x1,x2]=.5[x3,x4];
  y5=y7=y9;
  y6=y8=y10;
  y5-y6=usR_iht;
  .5[y5,y6]=y1;
  x7-x5=x9-x7=x11-x9=x8-x6=x10-x8;
  x6=.5[x5,x7];
  x8-x6=(usR_wd-usR_iwd);
  x5-x3=usR_f*(x8-x6);
  pickup pensquare scaled normalline;
  draw z1--z3--z5--z6--z7--z8--z9--z10--z4--z2;
enddef;

vardef usR_var =
  {{
  addxTF(shifted -z6 rotated -90);
  usR;
  pickup pensquare scaled normalline;
  arrow(z6,.8res_ara,.5usR_iht,res_phi,arr_lt,arr_phi)
    (pickup pencircle scaled normalline);
  }}
enddef;

def resistor_var =
  {{
  addxTF(shifted -z8 rotated -90);
  resistor;
  pickup pensquare scaled normalline;
  arrow(z8,res_ara,0,res_phi,arr_lt,arr_phi)
    (pickup pencircle scaled normalline);
  }}
enddef;

def capacitor =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(cap_lt-cap_spc);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(cap_spc,0);
  z3=z2+(pl,0);
  z4-z5=z6-z7=(0,cap_ht);
  z1=.5[z4,z5];
  z2=.5[z6,z7];
  draw z0--z1;
  draw z2--z3;
  draw z4--z5;
  draw z6--z7;
enddef;

def capacitor_var =
  capacitor;
  noarrowTF;
  pickup pencircle scaled thinline;
  arrow(.5[z1,z2],cap_ara,cap_arb,cap_phi,arr_lt,arr_phi)();
enddef;

def electrolytic_capacitor =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(cap_lt-cap_spc-cap_wd);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(cap_spc,0);
  z3=z2+(cap_wd,0);
  z4=z3+(pl,0);
  z5-z6=z7-z8=z9-z10=(0,cap_ht);
  z1=.5[z5,z6];
  z2=.5[z7,z8];
  z3=.5[z9,z10];
  draw z0--z1;
  draw z3--z4;
  draw z5--z6;
  draw z7--z9--z10--z8--cycle;
enddef;


"Widerstand";
twochars(0)(resistor)(.5res_ht#,res_lt#,.5res_ht#);

"US Widerstand";
twochars(24)(usR)(.5res_ht#,res_lt#,.5res_ht#);

"Widerstand variabel";
eightchars(8)(resistor_var)(res_y#,res_lt#-res_x#,res_x#,res_o#);

"US Widerstand variabel";
eightchars(32)(usR_var)(res_y#,res_lt#-res_x#,res_x#,res_o#);

"Kondensator";
twochars(128)(capacitor)(.5cap_ht#,cap_lt#,.5cap_ht#);

"Kondensator variabel";
twochars(130)(capacitor_var)(.5cap_ht#,cap_lt#,.5cap_ht#);

"Elektrolyt-Kondensator";
fourchars(136)(electrolytic_capacitor)(z4)(.5cap_ht#,cap_lt#,.5cap_ht#);

end;
%</csywidko>
%
%^^A last update: Fri  03-13-1998
%
%<*csym>
mode_setup;

% alle Symbole in einem 7pt Raster definieren
lLE#      :=7pt#;
define_whole_pixels(lLE);

% Liniest"arke und deren Variationen
linethickness#:= 0.45pt#;
thinline#     := 0.5linethickness#;
normalline#   := 1.0linethickness#;
thickline#    := 1.5linethickness#;
verythickline#:= 2.5linethickness#;
define_whole_blacker_pixels(normalline,thinline,thickline,verythickline);

fontdimen6: 1lLE#;

% *_ht  means the total height  !!! only <integer>*lLE#
% *_lt  means the total length  !!! only <integer>*lLE#

% *_spc means an inner  space
% *_spx means an inner  x-space
% *_spy means an inner  y-space
% *_wd  means an inner  width
% *_rad means a         radius
% *_dia means a         diameter
% *_phi means an        angle
% *_psi means an        angle

%box symbol
box_wd#  := 4lLE#;
define_pixels(box_wd);

%oscillograph
osc_dia# := 3lLE#;
osc_t    := .75;    % settings from Andreas Tille
osc_spc  := .5lLE;
define_pixels(osc_dia);

%wwire
ww_spc   := .25lLE;

darr_ht# := 1.3lLE#;
darr_lt# := 1lLE#;
darr_phi := 10;
darr_rad := 1lLE;
define_pixels(darr_ht,darr_lt);


bnd_lt# := 1lLE#;
bnd_phi := 60;
define_pixels(bnd_lt);

dsw_wd# := 4lLE#;
dsw_ht# := 2lLE#;
dsw_ov  := .2lLE;
dsw_t   := .2;
dsw_cc  := .35;
dsw_c   := .3;
dsw_phi := 12;
define_pixels(dsw_wd,dsw_ht);


tri_lt   := 0.8lLE;
tri_phi  := 18;

arr_lt   := 0.8lLE;
arr_phi  := 10;


%capacitor
cap_wd   :=  .4lLE;      %only for electrolytic capacitor
cap_spx  := .32lLE;      %only for electrolytic capacitor
cap_spy  :=  .5lLE;      %only for electrolytic capacitor
cap_rad  :=  .4lLE;
cap_spc  := .32lLE;
cap_ht#  :=   2lLE#;
cap_lt#  :=   2lLE#;
cap_phi  :=   45;
cap_ara  :=   1.4lLE;
cap_arb  :=   1.2lLE;
define_pixels(cap_lt,cap_ht);

%resistor
res_wd   :=   3lLE;
res_ht#  :=   1lLE#;
res_lt#  :=   4lLE#;
res_ara# :=  3.3lLE#;
res_phi  :=   45;
res_x#   :=   1lLE#;
res_y#   :=   1lLE#;
res_o#   :=   res_ara#*cosd(res_phi)-res_y#;
define_pixels(res_lt,res_ht,res_x,res_y,res_o,res_ara);

%diode
did_wd   :=   1.5lLE;
did_ht#  :=   1.5lLE#;
did_lt#  :=   3lLE#;
did_zlt  :=   .4lLE;
Dcap_ht  := .5lLE;
Dcap_spc := .15lLE;
Dcap_wd  := .35lLE;
define_pixels(did_lt,did_ht);

thy_ht# := 1lLE#;
define_pixels(thy_ht);

%led
% >wd ht lt< same as diode
% led_* means values for the arrows
led_lt#  :=   1.5lLE#;
led_wd   :=  .8lLE;
led_phi  :=  10;       %aperture-angle of arrows
led_psi  :=  50;       %angle of arrows from baseline
led_spc  := .4lLE;     %space between arrows
led_spx  :=  .4lLE;
led_spy#  := .8lLE#;
define_pixels(led_spy, led_lt);


%transistor
pnp_dis  :=  0.18;
npn_dis  :=  (1-pnp_dis);
tst_fac  :=  0.23333;
tst_phi  :=  20;
tst_iht  :=  3lLE;
tst_wd#  :=  1lLE#;
tst_lt#  :=  2lLE#;
tst_ht#  :=  4lLE#;
define_pixels(tst_ht,tst_lt,tst_wd);

%crystal
cry_wd   :=  .8lLE;
cry_spc  := .32lLE;
cry_ht#  :=   2lLE#;
cry_lt#  :=   4lLE#;
define_pixels(cry_lt,cry_ht);

%input/output connection
ioc_dia  := .5lLE;
ioc_ht#  := .5lLE#;
ioc_lt#  :=   1lLE#;
ioc_arr  := 0.7lLE;
ioc_phi  :=  12;
define_pixels(ioc_ht,ioc_lt);

%connection dot
cdt_dia  := .4lLE;
cdt_ht#  := .4lLE#;
cdt_lt#  := .2lLE#;
define_pixels(cdt_ht,cdt_lt);

%GND
GND_wd#  := 1.4res_ht#;
gnd_wd#  := 1.8lLE#;
gnd_ht#  :=   1lLE#;
gnd_spc#  := .2lLE#;
gnd_q    := .7;
define_pixels(gnd_ht,gnd_spc,gnd_wd,GND_wd);

%gate
inv_rad  :=  .36lLE;
gat_ht#  :=   5lLE#;
gat_lt#  :=   7lLE#;
define_pixels(gat_lt,gat_ht);

bbd_wd# := 6lLE#;
bbd_ht# := 10lLE#;
bba_wd# := 8lLE#;
bba_ht# := 4lLE#;
define_pixels(bbd_wd,bbd_ht,bba_wd,bba_ht);

%big integrated circuits
pin_lt#  :=   2lLE#;  % pin length
ios_wd#  :=   2.5lLE#;  % in out space
mid_wd#  :=   0lLE#;  % middle width
pin_spc# :=   2lLE#;  % pin space
out_spc# :=   1lLE#;  % outer space between pin and box

define_pixels(pin_lt,ios_wd,mid_wd,pin_spc,pin_wht,out_spc);

%value
val_lt#  :=   2lLE#;
val_phi  :=   7;
val_lft  :=   0;
val_rht  :=   0.9;
val_ht#  :=   .2lLE#;
define_pixels(val_lt,val_ht);

%circle
cir_ht#  :=  1.2lLE#;
cir_lt#  :=  4lLE#;
cir_phi  :=  45;
cir_ara  :=  2.2lLE;
cir_arb  :=  1.8lLE;
define_pixels(cir_ht,cir_lt);

%usource
uso_ht#  :=  1.5lLE#;
uso_lt#  :=  4lLE#;
uso_min  :=  1lLE;
uso_pls  :=  3lLE;
uso_spc  := .5lLE;
uso_rad  :=  3lLE;
uso_dis  := 0.2;
uso_phi  := 45;
uso_ara  := 1.6lLE;
uso_arb  := .8lLE;
define_pixels(uso_ht,uso_lt);

%isource
iso_ht#  := 1.2lLE#;
iso_lt#  := 4lLE#;
iso_dis  := 0.7;
iso_rad  :=  .8lLE;
iso_phi  := 45;
iso_ara  := 2.2lLE;
iso_arb  := 1.8lLE;
define_pixels(iso_ht,iso_lt);

%coil
coi_ht#  :=  .35lLE#;
coi_lt#  :=    4lLE#;
define_pixels(coi_ht,coi_lt);
coi_rad  :=  coi_ht;
coi_num  :=    4;

%switch
swt_lt#  :=  4lLE#;
swt_phi  :=  30;
swt_dis  :=  0.3;
swt_ind  :=  0.8;
swt_slt  :=  0.4lLE;
swt_ht#  := (1-2swt_dis)*sind(swt_phi)*swt_lt#;
define_pixels(swt_ht,swt_lt);

%OPV
opv_ht#  := 4.5lLE#;
opv_lt#  := 14lLE#;
opv_dis#  := 3lLE#;
opv_frc  := 1.1;
define_pixels(opv_lt,opv_ht,opv_dis);

%FET
fet_SD#  :=  4lLE#;     % Source--Drain
fet_GSx# :=  2lLE#;     % Gate--Source, x
fet_GSy# :=  1lLE#;     % Gate--Source, y
fet_Gsub :=  1lLE;      % Gate--Substrat
fet_soSD :=  0.3lLE;    % Substrat "uber Source und Drain
fet_sarr :=  0.2lLE;    % Substrat--Pfeil
define_pixels(fet_SD,fet_GSx,fet_GSy);


%MOSFET
mos_SD#  := fet_SD#;
mos_GSx# := fet_GSx#;
mos_GSy# := fet_GSy#;

mos_sd   := 2.3lLE;
mos_Gsub := fet_Gsub;
mos_ox   := 0.3lLE;
mos_soSD := fet_soSD;
mos_rad  := 0.2lLE;
define_pixels(mos_SD,mos_GSx,mos_GSy);

sym# := 232/36pt#;
define_pixels(sym);

% ############
% definitions
% ############

% for proofing mark all points
extra_endchar:=extra_endchar & "labels(range 0 thru 30);";

def {{ =
   begingroup
   save T; transform T;
   T:=currenttransform;
   save currenttransform;
   transform currenttransform;
   currenttransform:=T;
enddef;

def }} = endgroup; enddef;

def noarrowTF =
  transform _aT;
  numeric _x[],_y[];
  _aT:=currenttransform;
  for $=1 upto 20 : _x[$]:=x[$]; _y[$]:=y[$]; endfor;
  endgroup;
  for $=1 upto 20 : x[$]:=_x[$]; y[$]:=_y[$]; endfor;
  {{
enddef;

def addTF(text t) = currenttransform:=currenttransform t; enddef;
def addxTF(text t) = currenttransform:=(identity t) transformed
                     currenttransform; enddef;

def triangle(expr p, l, alpha, phi) =
  pair iz[];
  iz0=(0,0);
  iz1=iz0+((l,0) rotated (alpha+phi));
  iz2=iz0+((l,0) rotated (-alpha+phi));
  fill ((iz0--iz1--iz2--cycle) shifted round(p));
enddef;

def arrow(expr p, a, b, phi, l, alpha)(text doother) =
  pair iz[];
  iz0=(0,0);
  iz1=iz0-((l,0) rotated (alpha+phi));
  iz2=iz0-((l,0) rotated (-alpha+phi));
  iz3=p transformed if known _aT : _aT; else: identity; fi;
  iz3-iz4=(b,0) rotated phi;
  iz5-iz3=(a,0) rotated phi;
  iz6-iz3=(a-3*rt(0),0) rotated phi;
  draw iz4--iz6;
  doother;
  draw ((iz1--iz0--iz2) shifted round(iz5));
  transform _aT; %Transformation l"oschen
enddef;

def fillarrow(expr p, a, b, phi, l, alpha)(text doother) =
  pair iz[];
  iz0=(0,0);
  iz1=iz0-((l,0) rotated (alpha+phi));
  iz2=iz0-((l,0) rotated (-alpha+phi));
  iz3=p transformed if known _aT : _aT; else: identity; fi;
  iz3-iz4=(b,0) rotated phi;
  iz5-iz3=(a,0) rotated phi;
  iz6-iz3=(a-3*rt(0),0) rotated phi;
  draw iz4--iz6;
  doother;
  fill ((iz1--iz0--iz2--cycle) shifted round(iz5));
  transform _aT; %Transformation l"oschen
enddef;

lightarr_spc#=.5lLE#;
lightarr_lt#=1.5lLE#;
lightarr_alt=round(.7lLE);
lightarr_awd=round(.2lLE);
define_pixels(lightarr_spc,lightarr_lt);
def lightarrows(expr zpoint,lightarr_psi) =
  z100=zpoint;
  x100=x103=x105;
  x101=x104=x106=x100+lightarr_lt;
  y103=y104=y100+.5lightarr_spc;
  y105=y106=y100-.5lightarr_spc;
  x107=x108=x109=x110=x104-lightarr_alt;
  y107-y108=y109-y110=good.y(lightarr_awd);
  .5[y107,y108]=y104;
  .5[y109,y110]=y106;
  pickup pensquare scaled normalline rotated lightarr_psi;
  draw (z107--z104--z108--cycle) rotatedaround(z100,lightarr_psi);
  draw (z109--z106--z110--cycle) rotatedaround(z100,lightarr_psi);
  draw (z103--z104) rotatedaround(z100,lightarr_psi);
  draw (z105--z106) rotatedaround(z100,lightarr_psi);

enddef;


def eightchars(expr cfchar)   % erster Zeichenkode
              (text dochar)   % Zeichenkommandos
              (expr x, yf, ys, o) = % Abst"ande

  beginchar(cfchar,x,ys,yf); charic:=o;
    dochar;
  endchar;
  beginchar(cfchar+1,x,ys,yf); charic:=o;
    {{addTF(reflectedabout(up,down)); dochar;}}
  endchar;
  beginchar(cfchar+2,yf,x,o+x); charic:=ys;
    {{addTF(rotated 270); dochar;}}
  endchar;
  beginchar(cfchar+3,yf,x+o,x); charic:=ys;
    {{addTF(rotated 270); addTF(reflectedabout(left,right)); dochar;}}
  endchar;
  beginchar(cfchar+4,x,yf,ys); charic:=o;
    {{addTF(reflectedabout(left,right)); dochar;}}
  endchar;
  beginchar(cfchar+5,x,yf,ys); charic:=o;
    {{addTF(rotated 180); dochar;}}
  endchar;
  beginchar(cfchar+6,ys,x,x+o); charic:=yf;
    {{addTF(rotated 270); addTF(reflectedabout(up,down)); dochar;}}
  endchar;
  beginchar(cfchar+7,ys,x+o,x); charic:=yf;
    {{addTF(rotated 90); dochar;}}
  endchar;
enddef;

def twochars(expr cfchar)(text dochar)(expr ht, wd, dp) =
  beginchar(cfchar,wd,ht,dp);
    dochar;
  endchar;
  beginchar(cfchar+1,dp,wd,ht);
    {{addTF(rotated 90); dochar;}}
  endchar;
enddef;

def fourchars(expr cfchar)(text dochar)(text op)(expr ht, wd, dp) =
  beginchar(cfchar,wd,ht,dp);
    dochar;
  endchar;
  beginchar(cfchar+1,dp,wd,ht);
    {{addTF(rotated 90); dochar;}}
  endchar;
  beginchar(cfchar+2,wd,dp,ht);
    {{addTF(shifted -op rotated 180); dochar;}}
  endchar;
  beginchar(cfchar+3,ht,wd,dp);
    {{addTF(shifted -op rotated -90); dochar;}}
  endchar;
enddef;

def fourfourchars(expr cfchar)(text dochar)(text op)(expr ht, wd, dp) =
  beginchar(cfchar,wd,ht,dp);
    dochar;
  endchar;
  beginchar(cfchar+1,dp,wd,ht);
    {{addTF(rotated 90); dochar;}}
  endchar;
  beginchar(cfchar+2,wd,dp,ht);
    {{addTF(shifted -op rotated 180); dochar;}}
  endchar;
  beginchar(cfchar+3,ht,wd,dp);
    {{addTF(shifted -op rotated -90); dochar;}}
  endchar;
  beginchar(cfchar+4,wd,dp,ht);
    {{addTF(reflectedabout(left,right)); dochar;}}
  endchar;
  beginchar(cfchar+5,ht,wd,dp);
    {{addTF(reflectedabout(left,right) rotated 90); dochar;}}
  endchar;
  beginchar(cfchar+6,wd,ht,dp);
    {{addTF(reflectedabout (left,right) shifted -op rotated 180); dochar;}}
  endchar;
  beginchar(cfchar+7,dp,wd,ht);
    {{addTF(reflectedabout(left,right) shifted -op rotated -90); dochar;}}
  endchar;
enddef;

% small description of >hshade< and >vshade<
%
% The shade macros fill areas with a 'patternpath'.
%
% >vshade< expect that the area is bound left and right by vertical
% lines, the upper and lower boundary is build by the two pathes
% >pa< and >pb<.
%
% >hshade< expect it vice versa.
%
% The >patternpath< is used to draw it on invisible points of a grid.
% These gridpoints have a distance of 'di'.

primarydef x gridmod y = if x>0: (x mod y) else: -(-x mod y) fi enddef;

def vshade(suffix pa, pb)(expr di, patternpath) = begingroup
  path vl;
  boolean ifshift;

  if not cycle patternpath:
    errmessage "patternpath has to be a cyclic path!" fi;

  interim smoothing:=0;                  %change local only
  interim autorounding:=0;

  ifshift:=true;
  ydi:=round(1.41di);                    % round against pattern in
  xdi:=round(di);                        % pattern
  if xdi<2: errmessage "di to small! di>=2" fi;
  xs:=xpart(point 0 of pa);
  xe:=xpart(point infinity of pa);
  if xs>xe: ye:=xe; xe:=xs; xs:=ye; fi   %force xs<xe
  xs:=xs+((xe-xs) mod xdi) / 2;          %adjust grid horizontally
  vl:=(xs,infinity)--(xs,-infinity);
  oys:=ypart(pa intersectionpoint vl);
  oys:=oys-.5ydi;                        %adjust grid vertically
  for xs:=xs step xdi until xe:
    vl:=(xs,infinity)--(xs,-infinity);   % new cut line
    ys:=ypart(pa intersectionpoint vl);
    ye:=ypart(pb intersectionpoint vl);
    ifshift:=not(ifshift);               %shift periodically
    sy:=ydi-((ys-oys) gridmod ydi);
    ys:=ys+sy if ifshift: if sy-.5ydi<0:+else:-fi .5ydi fi;
    for ys:=ys step if ys>ye:-fi ydi until ye:
      fill patternpath shifted (xs,ys);
    endfor
  endfor;
  endgroup
enddef;

def hshade(suffix pa, pb)(expr di, patternpath) = begingroup
  path hl;
  boolean ifshift;

  if not cycle patternpath:
    errmessage "patternpath has to be a cyclic path!" fi;

  interim smoothing:=0;                  %change local only
  interim autorounding:=0;

  ifshift:=true;
  xdi:=round(1.41di);                    % round against pattern in
  ydi:=round(di);                        % pattern
  if ydi<2: errmessage "di to small! di>=2" fi;
  ys:=ypart(point 0 of pa);
  ye:=ypart(point infinity of pa);
  if ys>ye: xe:=ye; ye:=ys; ys:=xe; fi   %force ys<ye
  ys:=ys+((ye-ys) mod ydi) / 2;          %adjust grid vertically
  hl:=(infinity,ys)--(-infinity,ys);
  oxs:=xpart(pa intersectionpoint hl);
  oxs:=oxs-.5ydi;                        %adjust grid horizontally
  for ys:=ys step ydi until ye:
    hl:=(infinity,ys)--(-infinity,ys);   % new cut line
    xs:=xpart(pa intersectionpoint hl);
    xe:=xpart(pb intersectionpoint hl);
    ifshift:=not(ifshift);               %shift periodically
    sx:=xdi-((xs-oxs) gridmod xdi);
    xs:=xs+sx if ifshift: if sx-.5xdi<0:+else:-fi .5xdi fi;
    for xs:=xs step if xs>xe:-fi xdi until xe:
      fill patternpath shifted (xs,ys);
    endfor
  endfor;
  endgroup
enddef;


endinput;
%</csym>
%
%^^A last update: Fri  03-13-1998
%
%<*csydiod>
input csym;
designsize:=1lLE#;

def diode =  % "uberarbeiten
  numeric pl;
  pl:=.5(did_lt-did_wd);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(did_wd,0);
  z3=z2+(pl,0);
  z4-z5=z6-z7=(0,did_ht);
  z1=.5[z4,z5];
  z2=.5[z6,z7];
  z8=z4+(did_zlt,0);
  z9=z0+(0,thy_ht);

  z10=.35[z5,z7];
  z11=z10-(.5Dcap_spc,0);
  z12=z10+(.5Dcap_spc,0);
  y13=y15; y14=y16;
  x13=x14; x15=x16;
  y13-y14=Dcap_ht;
  z11=.5[z13,z14];
  z12=.5[z15,z16];
  z17=z11-(Dcap_wd,0);
  z18=z12+(Dcap_wd,0);

  pickup pensquare scaled normalline;
  draw z0--z3;
  draw z4--z5;
  draw  z1--z6--z7--cycle;
enddef;

def Dcap =
  pickup pensquare scaled normalline;
  draw z17--z11;
  draw z13--z14;
  draw z15--z16;
  draw z12--z18;
enddef;

def led_arrows =  % "uberarbeiten
  numeric pl;
  numeric x[],y[];
  transform arr_a,arr_b;
  pickup pencircle scaled thickline;
  pl:=.5(did_lt-did_wd);
  z0=(0,0);
  z4=z0+(pl,0);
  z1=z0+(led_lt,0);
  (z1-z2)=(led_wd,0) rotated led_phi;
  (z1-z3)=(led_wd,0) rotated -led_phi;
  arr_a:=identity rotated led_psi shifted
         (z4+(led_spx+.5led_spc*cosd(led_psi),led_spy-.5led_spc*sind(led_psi)));
  arr_b:=identity rotated led_psi shifted
         (z4+(led_spx-.5led_spc*cosd(led_psi),led_spy+.5led_spc*sind(led_psi)));
  draw (z0--z1) transformed arr_a;
  draw (z0--z1) transformed arr_b;
  fill (z2--z1--z3--cycle) transformed arr_a;
  fill (z2--z1--z3--cycle) transformed arr_b;
enddef;

"Diode";
fourchars(0)(diode)(z3)(.5did_ht#,did_lt#,.5did_ht#);

"Z-Diode";
fourchars(4)(diode; draw z4--z8)(z3)(.5did_ht#,did_lt#,.5did_ht#);

"LED";
fourfourchars(8)(diode; lightarrows(.5[z1,z6]+(0,.5lLE),120))(z3)
(.5did_ht#+.5led_spy#+led_lt#*sind(led_psi),did_lt#,.5did_ht#);

"Kapazit"&ditto&"atsdiode";
fourchars(16)(diode; Dcap)(z3)(.5did_ht#,did_lt#,.65did_ht#);

"Thyristor";

end;
%</csydiod>
%^^A last update: Fri  03-13-1998
%
%<*csyrest>
input csym;
designsize:=.5lLE#;

def gaslamp =
  z0=(0,0);
  z4=z0+(.5,0)*lLE;
  y4=y3;
  x2=x1;
  x3=x4+3lLE;
  y2=y1+2lLE;
  y4=.5[y1,y2];
  x1=.5[x4,x3];

  x5=x0+1.1lLE;
  y5=y0;
  x7=x6=x5; y7-y6=.5lLE;
  .5[y7,y6]=y0;


  y8=y9=y0;
  x8=x0+4lLE;

  x9=x8-1.1lLE;

  pickup pencircle scaled normalline;
  draw superellipse(z3,z2,z4,z1,.75);
  draw z0--z5;
  draw z6--z7;
  draw z8--z9;
  pickup pencircle scaled .3lLE;
  drawdot z9;
enddef;

def switch =  %"uberarbeiten
  numeric pl;
  pl:=swt_lt*swt_dis;
  sl:=(1-2swt_dis)*swt_lt;
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+((sl,0) rotated swt_phi);
  z3=z1+(swt_ind*sl,0);
  z4=z0+(swt_lt,0);
  z5=z3+(0,swt_slt);
  pickup pensquare scaled normalline;
  draw z0--z1--z2;
  draw z3--z4;
  draw z3--z5;
enddef;


def dswitch =
  z0=(0,0);
  z1=dsw_t[z0,z0+(dsw_wd,0)];
  x2=x3=x4=x5=x0+((1-dsw_c)*dsw_wd);
  y0=.5[y2,y3]=.5[y4,y5];
  y2-y3=dsw_ht;
  y2-y4=dsw_cc*dsw_ht;
  y2=y6; y3=y7;
  x6-x3=x7-x3=dsw_c*dsw_wd;
  x8=x1+dsw_ov+((1-dsw_c-dsw_t)*dsw_wd);
  y8=sind(dsw_phi)*x8/cosd(dsw_phi);
  pickup pensquare scaled normalline;
  draw z0--z1--z8;
  draw z4--z2--z6;
  draw z5--z3--z7;
enddef;

def circle =  % "uberarbeiten
  numeric pl;
  pl:=.5cir_lt-cir_ht;
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z0+(.5cir_lt,0);
  z3=z1+(2cir_ht,0);
  z4=z3+(pl,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z3--z4;
  pickup pencircle scaled thickline;
  draw fullcircle scaled 2cir_ht shifted z2;
enddef;

def lamp =
  circle
  z10-z11=(2cir_ht,0) rotated 45;
  z12-z13=(2cir_ht,0) rotated -45;
  .5[z10,z11]=z2=.5[z12,z13];
  pickup pencircle scaled normalline;
  draw z10--z11;
  draw z12--z13;
enddef;

def circle_var =
  circle;
  pickup pencircle scaled thinline;
  noarrowTF;
  arrow(z2,cir_ara,cir_arb,cir_phi,arr_lt,arr_phi)();
enddef;

def usource =  %"uberarbeiten
  numeric pl;
  pl:=.5(uso_lt-uso_spc);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(uso_spc,0);
  z3=z2+(pl,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z2--z3;
  z1=.5[z4,z5]; x4-x5=0; y5-y4=uso_pls;
  z2=.5[z6,z7]; x6-x7=0; y7-y6=uso_min;
  pickup pensquare scaled thickline;
  draw z4--z5;
  draw z6--z7;
enddef;

def usource_var =
  usource;
  noarrowTF;
  pickup pencircle scaled thinline;
  arrow(.5[z1,z2],uso_ara,cir_arb,uso_phi,arr_lt,arr_phi)();
enddef;


def isource =  %"uberarbeiten
  numeric pl;
  pl:=.5(iso_lt-(4-iso_dis)*iso_rad);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(iso_rad,0);
  z3=z2+((2-iso_dis)*iso_rad,0);
  z4=z3+(iso_rad,0);
  z5=z4+(pl,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z4--z5;
  pickup pencircle scaled thickline;
  draw fullcircle scaled (2*iso_rad) shifted z2;
  draw fullcircle scaled (2*iso_rad) shifted z3;
enddef;

def isource_var =
  isource;
  noarrowTF;
  pickup pencircle scaled thinline;
  arrow(.5[z2,z3],iso_ara,iso_arb,iso_phi,arr_lt,arr_phi)();
enddef;

def value = % "uberarbeiten
  z0=(0,0);
  z1=z0+(val_lt,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
  z2=val_lft[z0,z1];
  z3=val_rht[z0,z1];
  triangle(z2,abs(z3-z2),val_phi,0);
enddef;

def coil =  %"uberarbeiten
  numeric pl;
  pl:=.5(coi_lt-2coi_num*coi_rad);
  z0=(0,0);
  z1=z0+(pl,0);
  z2=z1+(coi_rad,0);
  for m=1 upto coi_num-1: z[m+2]=z[m+1]+(2coi_rad,0); endfor;
  z[2+coi_num]=z[1+coi_num]+(coi_rad,0);
  z[3+coi_num]=z[2+coi_num]+(pl,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z[2+coi_num]--z[3+coi_num];
  pickup pencircle scaled normalline;
  for m=1 upto coi_num: draw halfcircle scaled 2coi_rad shifted z[m+1]; endfor;
enddef;

def crystal =  %"uberarbeiten
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(cry_lt-2cry_spc-cry_wd);
  z0=(0,0); z1=z0+(pl,0);
  z2=z1+(cry_spc,0);
  z3=z2+(cry_wd,0);
  z4=z3+(cry_spc,0);
  z5=z4+(pl,0);
  z6-z7=z8-z9=z10-z11=z12-z13=(0,cry_ht);
  z2=.5[z6,z7]; z3=.5[z8,z9]; z1=.5[z10,z11]; z4=.5[z12,z13];
  draw z0--z1; draw z4--z5; draw z10--z11; draw z12--z13;
  draw z7--z9--z8--z6--cycle;
enddef;

def inout =  % "uberarbeiten
    z0=(ioc_lt,0);
    pickup pensquare scaled normalline;
    z2=z0+(ioc_lt,0);
    lft(z1)=z0+(.5ioc_dia,0);
    draw z1--z2;
enddef;

def minout =
  z0=(0,0);
  z1=z0+(ioc_lt,0);
  pickup pensquare scaled normalline;
  arrow(z0,0,ioc_lt,180,ioc_arr,ioc_phi)(pickup pencircle scaled normalline);
enddef;

def ground =                     % Masse z0 z11
  z0=(0,0); x1=x0=x2=x3;
  y0-y1=gnd_ht;
  y1-y2=y2-y3=gnd_spc;
  y4=y1=y10; y2=y6; y3=y8;
  z1=.5[z4,z5];     x5-x4=gnd_wd;
  z1=.5[z10,z11]; x11-x10=GND_wd;
  z2=.5[z6,z7]; x7-x6=gnd_wd*gnd_q;
  z3=.5[z8,z9]; x9-x8=gnd_wd*gnd_q*gnd_q*gnd_q;
enddef;

"Spule";
fourchars(0)(coil)(z[3+coi_num])(coi_ht#,coi_lt#,0);

"Quarz";
twochars(4)(crystal)(.5cry_ht#,cry_lt#,.5cry_ht#);

"Lampe";
twochars(6)(lamp)(cir_ht#,cir_lt#,cir_ht#);

"Kreise mit Anschl"&ditto&"ussen";
twochars(8)(circle)(cir_ht#,cir_lt#,cir_ht#);

"Kreise mit Anschl"&ditto&"ussen variabel";
twochars(10)(circle_var)(cir_ht#,cir_lt#,cir_ht#);

"Stromquelle";
twochars(12)(isource)(iso_ht#,iso_lt#,iso_ht#);

"Stromquelle variabel";
twochars(14)(isource_var)(iso_ht#,iso_lt#,iso_ht#);

"Spannungsquelle";
fourchars(16)(usource)(z3)(uso_ht#,uso_lt#,uso_ht#);

"Spannungsquelle variabel";
fourchars(20)(usource_var)(z3)(uso_ht#,uso_lt#,uso_ht#);

"Schalter";
twochars(24)(switch)(swt_ht#,swt_lt#,0);

"Umschalter";
eightchars(32)(dswitch)(dsw_wd#,.5dsw_ht#,.5dsw_ht#,0);

"Stromquelle variante";
twochars(44)(circle;
             pickup pencircle scaled normalline;
             draw z1--z3;)(cir_ht#,cir_lt#,cir_ht#);

"Spannungsquelle variante";
twochars(46)(circle;
             pickup pencircle scaled normalline;
             draw (z1--z3) rotatedaround (z2,90);)(cir_ht#,cir_lt#,cir_ht#);


"Gas-Lamp";
fourchars(40)(gaslamp)(z0)(1.5lLE#,4lLE#,1.5lLE#);

"Stromquelle variante";
twochars(44)(circle;
             pickup pencircle scaled normalline;
             draw z1--z3;)(cir_ht#,cir_lt#,cir_ht#);

"Spannungsquelle variante";
twochars(46)(circle;
             pickup pencircle scaled normalline;
             draw (z1--z3) rotatedaround (z2,90);)(cir_ht#,cir_lt#,cir_ht#);

"Anschl"&ditto&"usse Pfeil";
fourchars(232)
         (minout;)(z1)(.5ioc_ht#,2ioc_lt#,.5ioc_ht#);

"Anschl"&ditto&"usse leer";
fourchars(240)
         (inout;
          pickup pencircle scaled thinline;
          draw fullcircle scaled ioc_dia shifted z0;
         )(z2)(.5ioc_ht#,2ioc_lt#,.5ioc_ht#);

"Anschl"&ditto&"usse voll";
fourchars(244)
         (inout;
          pickup pencircle scaled ioc_dia;
          draw z0;
         )(z2)(.5ioc_ht#,2ioc_lt#,.5ioc_ht#);

"Str"&ditto&"ome";
fourchars(248)(value;)(z1)(val_ht#,val_lt#,val_ht#);

"wwire half R";
beginchar(112,.5lLE#,0pt,0pt);
  z0=(0,0);
  y4-y3=y2-y1=ww_spc;
  x3-x1=.5lLE;
  x0=x1=x2;
  x3=x4;
  y0=.5[y1,y2]=.5[y3,y4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;

"wwire R";
beginchar(113,1lLE#,0pt,0pt);
  z0=(0,0);
  y4-y3=y2-y1=ww_spc;
  x3-x1=1lLE;
  x0=x1=x2;
  x3=x4;
  y0=.5[y1,y2]=.5[y3,y4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;

"wwire half L";
beginchar(114,.5lLE#,0pt,0pt);
  z0=(0,0);
  y4-y3=y2-y1=ww_spc;
  x3-x1=.5lLE;
  x0=x3=x4;
  x1=x2;
  y0=.5[y1,y2]=.5[y3,y4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;

"wwire half U";
beginchar(115,0pt,.5lLE#,0pt);
  z0=(0,0);
  x4-x3=x2-x1=ww_spc;
  y3-y1=.5lLE;
  y0=y1=y2;
  y3=y4;
  x0=.5[x1,x2]=.5[x3,x4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;

"wwire U";
beginchar(116,0pt,1lLE#,0pt);
  z0=(0,0);
  x4-x3=x2-x1=ww_spc;
  y3-y1=1lLE;
  y0=y1=y2;
  y3=y4;
  x0=.5[x1,x2]=.5[x3,x4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;

"wwire half D";
beginchar(117,0pt,0pt,.5lLE#);
  z0=(0,0);
  x4-x3=x2-x1=ww_spc;
  y3-y1=.5lLE;
  y0=y3=y4;
  y1=y2;
  x0=.5[x1,x2]=.5[x3,x4];
  pickup pensquare scaled normalline;
  draw z1--z3;
  draw z2--z4;
endchar;


"dashed halfline R";
beginchar(120,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(.25lLE,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"dashed line R";
beginchar(121,1lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(1lLE,0);
  z2=.25[z0,z1];
  z3=.75[z0,z1];
  pickup pensquare scaled normalline;
  draw z2--z3;
endchar;

"dashed halfline L";
beginchar(122,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0-(.25lLE,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"dashed halfline U";
beginchar(123,0pt,.5lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,.25lLE);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"dashed line U";
beginchar(124,0pt,1lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,1lLE);
  z2=.25[z0,z1];
  z3=.75[z0,z1];
  pickup pensquare scaled normalline;
  draw z2--z3;
endchar;

"dashed halfline D";
beginchar(125,0pt,0pt,.5lLE#);
  z0=(0,0);
  z1=z0-(0,.25lLE);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie horizontal halb R";
beginchar(128,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(.5lLE,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie horizontal R";
beginchar(129,1lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(1lLE,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie horizontal halb L";
beginchar(130,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0-(.5lLE,0);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie vertikal halb U";
beginchar(131,0pt,.5lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,.5lLE);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie vertikal U";
beginchar(132,0pt,1lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,1lLE);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"Linie vertikal halb D";
beginchar(133,0pt,0pt,.5lLE#);
  z0=(0,0);
  z1=z0-(0,.5lLE);
  pickup pensquare scaled normalline;
  draw z0--z1;
endchar;

"B"&ditto&"undel horizontal";
beginchar(134,0,.8bnd_lt#,0pt);
  z0=(0,0);
  z0=.5[z2,z3];
  z3-z2=(bnd_lt,0) rotated bnd_phi;
  pickup pencircle scaled thinline;
  draw z2--z3;
endchar;

"B"&ditto&"undel vertikal";
beginchar(135,.8bnd_lt#,0pt,0pt);
  z0=(0,0);
  z0=.5[z2,z3];
  z3-z2=(bnd_lt,0) rotated (90-bnd_phi);
  pickup pencircle scaled thinline;
  draw z2--z3;
endchar;

"Linie fett horizontal R";
beginchar(136,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(.5lLE,0);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Linie fett horizontal R";
beginchar(137,1lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0+(1lLE,0);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Linie fett horizontal halb L";
beginchar(138,.5lLE#,0pt,0pt);
  z0=(0,0);
  z1=z0-(.5lLE,0);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Linie fett vertikal halb U";
beginchar(139,0pt,.5lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,.5lLE);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Linie fett vertikal U";
beginchar(140,0pt,1lLE#,0pt);
  z0=(0,0);
  z1=z0+(0,1lLE);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Linie fett vertikal halb D";
beginchar(141,0pt,0pt,.5lLE#);
  z0=(0,0);
  z1=z0-(0,.5lLE);
  pickup pensquare scaled 2normalline;
  draw z0--z1;
endchar;

"Oscillograph";
beginchar(142,osc_dia#,.5osc_dia#,.5osc_dia#);
  z0=(0,0);
  z1=z0;
  z5=.5[z1,z3]=.5[z2,z4];
  x2=x4;
  y1=y3;
  x3-x1=y4-y2=osc_dia;
  .5osc_gt+osc_spc+osc_stm=.5osc_dia;
  osc_stm=osc_t*osc_gt;
  z6=z1+(osc_stm,0);
  z7=z2+(0,osc_stm);
  z8=z3+(-osc_stm,0);
  z9=z4+(0,-osc_stm);
  z6=.5[z10,z11]; x10=x11; x16-x17=y14-y15=x12-x13=y11-y10=osc_gt;
  z7=.5[z12,z13]; y12=y13;
  z8=.5[z14,z15]; x14=x15;
  z9=.5[z16,z17]; y16=y17;
  pickup pensquare scaled normalline; %drawing style by Andreas Tille
  draw z1--z6;                        %code rewritten by SeTa
  draw z2--z7;
  draw z3--z8;
  draw z4--z9;
  pickup pencircle scaled normalline;
  draw fullcircle scaled osc_dia shifted z5;
  pickup pensquare scaled thickline;
  draw z10--z11;
  draw z12--z13;
  draw z14--z15;
  draw z16--z17;
endchar;

"a small grey elephant: Thanks to Andreas Tille.";
%
% The code is a little bit crazy.
%
LE#:=.03mm#;
define_pixels(LE);
numeric nPnt;
def p(expr px,py) = x[nPnt]:=px*LE; y[nPnt]:=py*LE; nPnt:=nPnt+1 enddef;

beginchar(252,540LE#,265LE#,274LE#);
  pickup pencircle scaled 0.4pt;
  path a, b;
  picture cutpic;
  nPnt:=0;

p(  0,  0);   % copyright by Sebastian Tannert
p(  0, 18);   % Please think of the hard work!
%
p( -2, 46);p( -3, 92);p(  8,117);p( 28,152);
p( 38,171);p( 71,195);p(107,218);p(138,240);p(159,255);p(181,261);
p(193,264);p(211,268);p(231,263);p(249,264);p(273,259);p(292,255);
p(311,249);p(336,240);p(380,222);p(414,208);p(437,198);p(449,193);
p(461,190);p(473,185);p(490,173);p(506,157);p(519,125);p(526, 91);
p(530, 56);p(530, 35);p(523, 17);p(518,  1);p(509,-22);p(511,-46);
p(515,-71);p(514,-96);p(512,-112);p(511,-135);p(507,-150);p(498,-171);
p(485,-184);p(465,-197);p(448,-200);p(429,-194);p(418,-177);p(414,-168);
p(420,-159);p(427,-157);p(435,-163);p(439,-171);p(449,-164);p(461,-165);
p(470,-152);p(476,-139);p(476,-118);p(475,-97);p(465,-76);p(450,-62);
p(442,-50);p(427,-36);p(417,-29);p(409,-27);p(392,-12);p(383,-10);
p(374,-18);p(370,-34);p(363,-58);p(347,-92);p(343,-106);p(341,-126);
p(330,-162);p(323,-196);p(322,-210);p(317,-237);p(327,-257);p(325,-268);
p(310,-270);p(301,-272);p(284,-266);p(269,-258);p(268,-236);p(270,-210);
p(282,-185);p(300,-151);p(315,-119);p(322,-93);p(325,-79);p(326,-63);
p(315,-75);p(303,-101);p(292,-134);p(281,-164);p(269,-189);p(258,-220);
p(259,-250);p(260,-266);p(252,-269);p(235,-260);p(221,-266);p(203,-261);
p(194,-242);p(201,-227);p(206,-213);p(207,-190);p(215,-162);p(222,-147);
p(225,-123);p(229,-96);p(234,-77);p(234,-65);p(236,-47);p(236,-30);
p(236,-12);p(240,6);p(248,19);p(264,37);p(146,41);p(158,24);
p(176,-3);p(188,-29);p(193,-53);p(185,-80);p(175,-106);p(165,-137);
p(152,-173);p(143,-202);p(142,-222);p(136,-232);p(141,-253);p(132,-255);
p(125,-255);p(105,-240);p(91,-239);p(75,-228);p(68,-205);p(70,-178);
p(85,-156);p(96,-127);p(100,-112);p(95,-88);p(79,-62);p(60,-38);
p(48,-16);p(36,18);p(28,63);p(24,41);p(28,17);p(29,-6);p(31,-32);
p(26,-43);p(17,-65);p(15,-83);p(12,-106);p(7,-126);p(0,-141);
p(-9,-147);p(-16,-131);p(-24,-110);p(-22,-94);p(-17,-75);p(-6,-55);
p(-2,-34);p(2,-19);p(190,-63);p(209,-75);p(234,-69);p(31,-32);
p(31,-44);p(26,-67);p(37,-95);p(45,-117);p(43,-158);p(38,-193);
p(25,-224);p(29,-249);p(52,-266);p(71,-264);p(88,-266);p(113,-273);
p(133,-273);p(138,-268);p(132,-255);p(457,48);p(462,30);p(481,21);
p(477,40);p(449,32);p(456,11);p(478,5);p(464,60);p(486,61);
p(499,37);p(363,93);p(352,110);p(348,129);p(358,149);p(386,162);
p(414,173);p(427,178);p(443,167);p(456,157);p(461,142);p(450,126);
p(436,110);p(419,74);p(409,53);p(396,40);p(372,51);p(365,67);
p(358,148);p(375,139);p(387,124);p(401,128);p(411,146);p(418,163);
p(427,168);p(443,167);p(444,161);p(434,152);p(432,135);p(440,124);
p(451,128);p(460,141);p(455,157);p(350,138);p(459,138);p(-30,276);
p(539,-283);p(539,276);p(-30,-283);p(427,-41);p(436,-54);

draw for i:=0 upto 109: z[i]..endfor
z110{up}..z167{curl.7}..z166..z165{curl.7}..z123{down}..
for i:=124 upto 144: z[i]..endfor z145---z146..z147{down}..
for i:=148 upto 164: z[i]..endfor z0;

draw for i:=110 upto 116: z[i].. endfor z117;
draw for i:=118   upto 122: z[i].. endfor z123{down};

draw for i:=168 upto 182: z[i].. endfor z183;


draw for i:=194 upto 210: z[i].. endfor cycle;

draw for i:=211 upto 217: z[i].. endfor z218;

a:= z226..z197..z198..z199..z200..z201..z202..z203..z227;
b:= z226--z227;
vshade(b,a,4,unitsquare scaled 1.8);

a:= z227..z206..z207..z208..z209..z210..z194..
    z195..z196..z226;
b:= z227--z226;
vshade(b,a,4,unitsquare scaled 1.8);

a:= z228--z230;
b:= z231--z229;
vshade(a,b,4,unitsquare);

cutpic=nullpicture;

addto cutpic contour(z228+(0,10)--z230+(10,10)--z229--z231--cycle);

pickup pencircle scaled 0.7pt

addto cutpic contour (for i:=0 upto 109: z[i].. endfor
     z110{up}..z167{curl.7}..z166..z165{curl.7}..z123{down}..
     for i:=124 upto 144: z[i].. endfor z145---z146..z147{down}..
     for i:=148 upto 164: z[i].. endfor cycle) withweight -1;

addto cutpic doublepath
     (for i:=0   upto 109: z[i].. endfor
     z110{up}..z167{curl.7}..z166..z165{curl.7}..z123{down}..
     for i:=124 upto 144: z[i].. endfor z145---z146..z147{down}..
     for i:=148 upto 164: z[i].. endfor z0) withpen currentpen
     withweight -1;

addto cutpic doublepath z232..z233 withpen currentpen withweight -1;

addto cutpic contour (for i:=168 upto 182: z[i].. endfor z183..z146..cycle)
  withpen currentpen withweight -1;

cull cutpic keeping (1,infinity) withweight -3;

addto currentpicture also cutpic;

pickup pencircle scaled .7pt;
draw z184..z185{z186-z184}..z186;
draw z186..z187{z184-z186}..z184;

draw z188..z189..z190;
draw z191..z192..z193;
draw z232..z233;

endchar;


"Masse";
beginchar(253,.5gnd_wd#,0,gnd_ht#+gnd_spc#+gnd_spc#);
  ground
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z4--z5;
  draw z6--z7;
  draw z8--z9;
endchar;

"MASSE";
beginchar(254,.5GND_wd#,0,gnd_ht#);
  ground
  pickup pensquare scaled normalline;
  draw z0--z1;
  pickup pensquare scaled verythickline;
  draw z10--z11;
endchar;

"Verbindungspunkt";
beginchar(255,cdt_lt#,.5cdt_ht#,.5cdt_ht#);
    pickup pencircle scaled cdt_dia;
    z0=(0,0);
    drawdot z0;
endchar;

end;
%</csyrest>
%
%^^A last update: Fri  03-13-1998
%<*optic>
input csym;

string optionname; optionname="optics";

font_identifier="cioptic";

input defcirc;

% half of linelength of optical axis
hsoa:=.128CIu;

% lenses
% thin convex lens 
slens_ht#   :=   2CIu#;
slens_lt#   :=   2CIu#;
slens_phi   :=   60;
% lensthickness:
slens_spc   :=   .55CIu;
define_pixels(slens_lt,slens_ht);

% thick convex lens
blens_ht#   :=   2CIu#;
blens_lt#   :=   2CIu#;
blens_phi   :=   45;
blens_spc   :=   .88CIu;
define_pixels(blens_lt,blens_ht);

% thin concave lens
sklens_ht#  :=   2CIu#;
sklens_lt#  :=   2CIu#;
sklens_phi  :=   60;
sklens_spc  :=   .58CIu;
sklens_bt   :=   1CIu;     % Breite Bottom und Top
define_pixels(sklens_lt,sklens_ht);

% mirror
mir_ht#     :=  2CIu#;
mir_lt#     :=  2CIu#;
mir_wd      :=  .5CIu;    % Schraffurl"ange
define_pixels(mir_ht,mir_lt);

% boxes for optical modulator and laser
omb_wd# := 3CIu#;
omb_ht# := 2CIu#;
lab_wd# := 4CIu#;
lab_ht# := 2CIu#;
define_pixels(omb_wd,omb_ht,lab_wd,lab_ht);

% polarizer
pol_ht#  :=  2CIu#;
pol_lt#  :=  2CIu#;
pol_spc  := .2CIu;
define_pixels(pol_ht,pol_lt);

% pinhole
pin_ht#  :=  2CIu#;
pin_lt#  :=  2CIu#;
pin_spx  := .16CIu;
pin_spy  := .08CIu;
pin_spz  := .5CIu;
define_pixels(pin_ht,pin_lt);

% camera
cam_ht#  := 2CIu#;
cam_lt#  := 3CIu#;
cam_spx  := 2CIu;
cam_spy  := 1CIu;
define_pixels(cam_ht,cam_lt);

% screen
scr_ht#  := 4CIu#;
scr_lt#  := 2CIu#;
scr_spx  := 1CIu;
scr_spy  := 1CIu;
define_pixels(scr_ht,scr_lt);

def rectangle(expr width, height, xs, ys) =
  draw (xs,.5height+ys)--(width+xs,.5height+ys)--(width+xs,-.5height+ys)--
       (xs,-.5height+ys)--cycle;
enddef;

def small_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(slens_lt-slens_spc);
  z0=(.5slens_lt,-.5slens_ht);
  z1=(.5slens_lt,.5slens_ht);
  z2=(.5CIu,0); z3=z2+(hsoa,0);
  z4=(slens_lt-.5CIu,0); z5=z4-(hsoa,0);
  draw z0{dir slens_phi}..z1;
  draw z0{dir (180-slens_phi)}..z1;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_small_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(slens_lt-slens_spc);
  z0=(.5slens_lt,-.5slens_ht);
  z1=(.5slens_lt,.5slens_ht);
  z4=(slens_lt-.5CIu,0); z5=z4-(hsoa,0);
  draw z0{dir slens_phi}..z1;
  draw z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def bold_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(blens_lt-blens_spc);
  z0=(.5blens_lt,-.5blens_ht);
  z1=(.5blens_lt,.5blens_ht);
  draw z0{dir blens_phi}..z1;
  draw z0{dir (180-blens_phi)}..z1;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_bold_lens =
  pickup pensquare scaled normalline;
  numeric pl;
  pl:=.5(blens_lt-blens_spc);
  z0=(.5blens_lt,-.5blens_ht);
  z1=(.5blens_lt,.5blens_ht);
  draw z0{dir blens_phi}..z1;
  draw z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def small_konkav_lens =
  pickup pensquare scaled normalline;
  numeric pl, ql;
  pl:=.5(sklens_lt-sklens_spc);
  ql:=.5(sklens_lt-sklens_bt);
  z0=(ql,-.5sklens_ht);
  z1=(sklens_lt-ql,-.5sklens_ht);
  z2=(ql,.5sklens_ht);
  z3=(sklens_lt-ql,.5sklens_ht);
  z4=(.5CIu,0); z5=z4+(hsoa,0);
  z6=(sklens_lt-.5CIu,0); z7=z6-(hsoa,0);
  draw z0{dir sklens_phi}..z2--z3{dir (180+sklens_phi)}..z1--z0;
  draw z4--z5; draw z6--z7;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def half_small_konkav_lens =
  pickup pensquare scaled normalline;
  numeric pl, ql;
  pl:=.5(sklens_lt-sklens_spc);
  ql:=.5(sklens_lt+sklens_bt);
  z0=(.5sklens_lt,-.5sklens_ht);
  z1=(ql,-.5sklens_ht);
  z2=(.5sklens_lt,.5sklens_ht);
  z3=(ql,.5sklens_ht);
  draw z0--z2--z3{dir (180+sklens_phi)}..z1--z0;
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def mirror =
  pickup pensquare scaled normalline;
  opticalaxis(normalline)(0);
  opticalaxisdown(normalline)(.5mir_lt,0);
  halfmirror;
  pickup pensquare scaled thinline;
  for i=.125 step .125 until .875:
     draw (i*mir_lt,(.5-i)*mir_ht)--(mir_wd+i*mir_lt,mir_wd+(.5-i)*mir_ht);
  endfor
enddef;
  
def halfmirror =
  pickup pensquare scaled thickline;
  draw (.5mir_wd,.5(mir_ht-mir_wd))--(mir_lt-.5mir_wd,.5(mir_wd-mir_ht));
enddef;

def halfmirrorline =
  pickup pensquare scaled normalline;
  opticalaxis(normalline)(0);
  opticalaxisdown(normalline)(.5mir_lt,.5mir_ht);
  opticalaxisdown(normalline)(.5mir_lt,0);
enddef;

def polarizer =
  pickup pensquare scaled thinline;
  numeric pl;
  pl:=.5(pol_lt-pol_spc);
  z0=(pl,.5pol_ht);
  z1=z0+(0,-pol_ht);
  z2=z1+(pol_spc,0);
  z3=z0+(pol_spc,0);
  draw z0--z1--z2--z3--cycle;
  % optical axis
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def pinhole =
  pickup pensquare scaled thinline;
  numeric pl;
  pl:=.5(pin_lt-pin_spx);
  fill (.5pin_lt,.5pin_spy)--(pl,.5pin_spz)--(pl,.5pin_ht)--
       (pl+pin_spx,.5pin_ht)--(pl+pin_spx,.5pin_spz)--cycle;
  fill (.5pin_lt,-.5pin_spy)--(pl,-.5pin_spz)--(pl,-.5pin_ht)--
       (pl+pin_spx,-.5pin_ht)--(pl+pin_spx,-.5pin_spz)--cycle;
  % optical axis
  opticalaxis(normalline)(0);
  opticalaxis(normalline)(1CIu);
enddef;

def screenleft (expr gray) =
  pickup pensquare scaled normalline;
  path a, b;
  numeric pl;
  pl:=.5(scr_lt-scr_spx);
  z0=(pl,.5scr_ht);
  z1=(pl+scr_spx,scr_spy);
  z2=(pl+scr_spx,-.5scr_ht);
  z3=(pl,-scr_spy);
  draw z0--z1--z2--z3--cycle;
  a:=z0--z1;
  b:=z2--z3;
  vshade(b, a, gray, unitsquare);
enddef;

def screenright (expr gray) =
  pickup pensquare scaled normalline;
  path a, b;
  numeric pl;
  pl:=.5(scr_lt-scr_spx);
  z0=(pl,-.5scr_ht);
  z1=(pl,scr_spy);
  z2=(pl+scr_spx,.5scr_ht);
  z3=(pl+scr_spx,-scr_spy);
  draw z0--z1--z2--z3--cycle;
  a:=z1--z2;
  b:=z3--z0;
  vshade(b, a, gray, unitsquare);
enddef;

% optical Axis as dashed line
def opticalaxis(expr linethickness)(expr offset) =
  pickup pensquare scaled linethickness;
  draw (offset,0)--(offset+hsoa,0);
  draw (offset+3hsoa,0)--(offset+5hsoa,0);
  draw (offset+7hsoa,0)--(offset+1CIu,0);
enddef;

% half optical Axis as dashed line
def halfopticalaxis(expr linethickness)(expr offset) =
  pickup pensquare scaled linethickness;
  draw (offset,0)--(offset+hsoa,0);
  draw (offset+3hsoa,0)--(offset+.5CIu,0);
enddef;

% optical Axis as dashed line downwards
def opticalaxisdown(expr linethickness)(expr xoffset, yoffset) =
  pickup pensquare scaled linethickness;
  draw (xoffset,yoffset)--(xoffset,yoffset-hsoa);
  draw (xoffset,yoffset-3hsoa)--(xoffset,yoffset-5hsoa);
  draw (xoffset,yoffset-7hsoa)--(xoffset,yoffset-1CIu);
enddef;

% half optical Axis as dashed line downwards
def halfopticalaxisdown(expr linethickness)(expr xoffset, yoffset) =
  pickup pensquare scaled linethickness;
  draw (xoffset,yoffset)--(xoffset,yoffset-hsoa);
  draw (xoffset,yoffset-3hsoa)--(xoffset,yoffset-.5CIu);
enddef;

% Camera
def camera =
  pickup pensquare scaled thickline;
  numeric pl;
  pl:=cam_lt-cam_spx;
  draw (pl,.25cam_spy)--(0,.5cam_spy)--(0,-.5cam_spy)--(pl,-.25cam_spy);
  draw (pl,.5cam_ht)--(pl,-.5cam_ht)--(cam_lt,-.5cam_ht)--(cam_lt,.5cam_ht)--cycle;
enddef;

"SmalCIuns";
twochars(0)(small_lens)(.5slens_ht#,slens_lt#,.5slens_ht#);

"HalfSmalCIuns";
fourchars(2)(half_small_lens)((slens_lt,0))(.5slens_ht#,slens_lt#,.5slens_ht#);

"BoldLens";
twochars(6)(bold_lens)(.5blens_ht#,blens_lt#,.5blens_ht#);

"HalfBoldLens";
fourchars(8)(half_bold_lens)((blens_lt,0))(.5blens_ht#,blens_lt#,.5blens_ht#);

"SmallKonkavLens";
twochars(12)(small_konkav_lens)(.5sklens_ht#,sklens_lt#,.5sklens_ht#);

"HalfSmallKonkavLens";
fourchars(14)(half_small_konkav_lens)((sklens_lt,0))(.5sklens_ht#,sklens_lt#,.5sklens_ht#);

"Mirror";
eightchars(85)(mirror)(.5mir_lt#,.5mir_ht#,.5mir_ht#,.5mir_lt#);

"BeamSplitter";
eightchars(36)(halfmirror;halfmirrorline)(.5mir_lt#,.5mir_ht#,.5mir_ht#,.5mir_lt#);

"Polarizer";
twochars(44)(polarizer)(.5pol_ht#,pol_lt#,.5pol_ht#);

"Pinhole";
twochars(46)(pinhole)(.5pin_ht#,pin_lt#,.5pin_ht#);

"Camera";
fourchars(66)(camera)((cam_lt,0))(.5cam_ht#,cam_lt#,.5cam_ht#);

"ScreenLeft";
twochars(72)(screenleft(2);opticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenRight";
twochars(74)(screenright(2);opticalaxis(normalline)(1CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenLeftBehind";
twochars(76)(screenleft(2);halfopticalaxis(normalline)(1.5CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"ScreenRightBehind";
twochars(78)(screenright(2);halfopticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"VScreenLeft";
twochars(80)(screenleft(4);opticalaxis(normalline)(0);halfopticalaxis(normalline)(1.5CIu))(.5scr_ht#,scr_lt#,.5scr_ht#);

"VScreenRight";
twochars(82)(screenright(4);opticalaxis(normalline)(1CIu);halfopticalaxis(normalline)(0))(.5scr_ht#,scr_lt#,.5scr_ht#);

"horizontal dashed half line to the right";
beginchar(128,.5CIu#,0pt,0pt);
   halfopticalaxis(normalline)(0);
endchar;

"horizontal dashed long line to the right";
beginchar(129,1CIu#,0pt,0pt);
   opticalaxis(normalline)(0);
endchar;

"horizontal dashed half line to the left";
beginchar(130,.5CIu#,0pt,0pt);
   halfopticalaxis(normalline)(-.5CIu);
endchar;

"horizontal dashed half line up";
beginchar(131,0pt,.5CIu#,0pt);
   halfopticalaxisdown(normalline)(0,.5CIu);
endchar;

"horizontal dashed long line up";
beginchar(132,0pt,1CIu#,0pt);
   opticalaxisdown(normalline)(0,1CIu);
endchar;

"horizontal dashed half line down";
beginchar(133,0pt,0pt,.5CIu#);
   halfopticalaxisdown(normalline)(0,0);
endchar;

"bold horizontal dashed half line to the right";
beginchar(136,.5CIu#,0pt,0pt);
   halfopticalaxis(2normalline)(0);
endchar;

"bold horizontal dashed long line to the right";
beginchar(137,1CIu#,0pt,0pt);
   opticalaxis(2normalline)(0);
endchar;

"bold horizontal dashed half line to the left";
beginchar(138,.5CIu#,0pt,0pt);
   halfopticalaxis(2normalline)(-.5CIu);
endchar;

"bold horizontal dashed half line up";
beginchar(139,0pt,.5CIu#,0pt);
   halfopticalaxisdown(2normalline)(0,.5CIu);
endchar;

"bold horizontal dashed long line up";
beginchar(140,0pt,1CIu#,0pt);
   opticalaxisdown(2normalline)(0,1CIu);
endchar;

"bold horizontal dashed half line down";
beginchar(141,0pt,0pt,.5CIu#);
   halfopticalaxisdown(2normalline)(0,0);
endchar;

% This is a part of mf-output from Gnuplot. It adds the possibility to
% use Text within METAFONT-Symbols
if unknown cmbase: input cmbase fi

tracingstats:=1;
picture r[];

def put_text(expr ts,xstart,ystart,rot,justification) =
  begingroup
    text_width:=0;text_height:=0;
    for ind:=0 step 1 until length(ts)-1:
      dec_num:=ASCII substring (ind,ind+1) of ts;
      if unknown r[dec_num]: dec_num:=32; fi
      if dec_num=32: 
        text_width:=text_width+wd[65];
        text_height:=max(text_height,ht[65]+dp[65]);
      elseif dec_num>=0: 
        text_width:=text_width+wd[dec_num];
        text_height:=max(text_height,ht[dec_num]+dp[dec_num]);
      fi
    endfor
    if rot=90:
      if justification=1: ynext:=ystart;
      elseif justification=2: ynext:=round(ystart-text_width/2);
      else: ynext:=round(ystart-text_width);
      fi
      xnext:=xstart+text_height/2;
    else:
      if justification=1: xnext:=xstart;
      elseif justification=2: xnext:=round(xstart-text_width/2);
      else: xnext:=round(xstart-text_width);
      fi
      ynext:=ystart-text_height/2;
    fi
    for ind:=0 step 1 until length(ts)-1:
      dec_num:=ASCII substring (ind,ind+1) of ts;
      if unknown r[dec_num]: dec_num:=32; fi
      if dec_num=32: 
        xnext:=xnext+wd[65]*cosd rot;
        ynext:=ynext+wd[65]*sind rot;
      elseif dec_num>=0: 
        currentpicture:=currentpicture+r[dec_num] shifted(xnext,ynext)
          rotatedaround ((xnext,ynext),rot); 
        xnext:=xnext+wd[dec_num]*cosd rot;
        ynext:=ynext+wd[dec_num]*sind rot;
      fi
    endfor
  endgroup 
enddef;

def endchar =
  r[charcode]:=currentpicture;
  wd[charcode]:=w;ht[charcode]:=h;dp[charcode]:=d;
  endgroup;
enddef;
let endchar_ = endchar;
let generate = relax;
let roman = relax;
input cmss10.mf
if ligs>1: font_coding_scheme:="TeX text";
else: font_coding_scheme:=
  if ligs=0: "TeX typewriter text"
  else: "TeX text without f-ligatures" fi;
fi
font_setup;
input romanu.mf %Roman uppercase.
input romanl.mf %Roman lowerrcase.

def endchar =
  % Next line should probably be removed if CM base is used
%  l:=0; r:=w;
  %Include the next two lines if you want to
  %rotate the picture 90 deg.(Portrait to Landscape)
  %currentpicture:=currentpicture rotated 90 shifted (h,0);
  %tmp:=charht; charht:=charwd; charwd:=tmp;
  scantokens extra_endchar;
  if proofing>0: makebox(proofrule); fi
  chardx:=w;
  shipit;
  if displaying>0: makebox(screenrule); showit; fi
  endgroup 
enddef;
let endchar_ = saveendchar;
let generate = input;
let roman = roman;
def t_ = transformed currenttransform enddef;
% End of Gnuplot-Part

"Laser Box horizontal";
beginchar(160,lab_wd#,.5lab_ht#,.5lab_ht#);
  pickup pensquare scaled thickline;
  rectangle(lab_wd,lab_ht,0,0);
  pickup pencircle scaled normalline;
  put_text("Laser",.5lab_wd,0,0,2);
endchar;

"Laser Box vertical";
beginchar(161,.5lab_ht#,lab_wd#,.5lab_ht#);
  pickup pensquare scaled thickline;
  rectangle(lab_ht,lab_wd,-.5lab_ht,.5lab_wd);
  pickup pencircle scaled normalline;
  put_text("Laser",0,.5lab_wd,90,2);
endchar;

"Photometer Box horizontal";
beginchar(162,omb_wd#,.5omb_ht#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_wd,omb_ht,0,0);
  pickup pencircle scaled normalline;
  put_text("PM",.5omb_wd,0,0,2);
endchar;

"Photometer Box vertical";
beginchar(163,.5omb_ht#,omb_wd#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_ht,omb_wd,-.5omb_ht,.5omb_wd);
  pickup pencircle scaled normalline;
  put_text("PM",0,.5omb_wd,90,2);
endchar;

"Optical Modulator Box horizontal";
beginchar(164,omb_wd#,.5omb_ht#,.5omb_ht#);
  pickup pensquare scaled thickline;
  rectangle(omb_wd,omb_ht,0,0);
  pickup pensquare scaled normalline;
  put_text("OM",.5omb_wd,0,0,2);
endchar;

"Optical Modulator Box vertical";
beginchar(165,omb_ht#,.5omb_wd#,.5omb_wd#);
  pickup pensquare scaled thickline;
  rectangle(omb_ht,omb_wd,0,0); %-.5omb_ht,.5omb_wd);
  pickup pensquare scaled normalline;
  put_text("OM",.5omb_ht,0,90,2);
endchar;

end;
%</optic>
%^^A last update: Fri  03-13-1998
%
%<*csycirc>
input csym;

designsize:=2lLE#;

fontdimen10: .4gat_ht#;
fontdimen11: .65gat_lt#;

fontdimen12: .5pin_lt#;
fontdimen13:  pin_spc#;
fontdimen14: .5ios_wd#+.5pin_lt#;
fontdimen15:  mid_wd#+ios_wd#;
fontdimen16:  ios_wd#;
fontdimen17:  out_spc#;

%fontdimen7:  .4gat_ht#;
%fontdimen8:  .5pin_lt#;
%fontdimen9:  .5(pin_lt#+ios_wd#);
%fontdimen10: .5mid_wd#;
%fontdimen11: .5ios_wd#;
%fontdimen16: pin_spc#;

def defcircleabout(expr p, rad)=
  z[p]=.5[z[p+1],z[p+3]]=.5[z[p+2],z[p+4]];
  y[p+1]=y[p+3];
  x[p+2]=x[p+4];
  x[p]=lft(x[p+1])-rad;
  y[p]=top(y[p+4])+rad;
enddef;

def gate=
  charic:=.5pin_spc#;
  z0=(0,0);
  x20=x15=x1=x6=x7=  x0+pin_lt;
  y8=y6=-y7=         y0+.5gat_ht;
  x8=x9=x10=         x1+gat_lt-2pin_lt;
  y15=-y20=          y0+.5pin_spc;
  x25-x0=            gat_lt;

  y9=y7; y25=y10=y1=y0;
  x0=x26=x27;
  y26=y15; y27=y20;

  pickup pencircle scaled thickline;
  defcircleabout(1,inv_rad);
  defcircleabout(10,inv_rad);
  defcircleabout(15,inv_rad);
  defcircleabout(20,inv_rad);
enddef;

def segment =
  z0=(0,0);
  x1-x0=pin_lt; y0=y1;
  defcircleabout(1,inv_rad); % z2 z3 z4 z5 defined
  z1=.5[z6,z7]; x6=x7=x8;
  y7-y6=pin_spc;
  y8-y1=out_spc;
  x9-x8=ios_wd; y8=y9;
enddef;


def topbotsegs(expr fc, myht, mydp) =
  beginchar(fc+0,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8--z9;
  endchar;
  beginchar(fc+1,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8--z9;
    pickup pensquare scaled normalline;
    draw z0--z1;
  endchar;
  beginchar(fc+2,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z5;
    draw z3--z8--z9;
    pickup pencircle scaled normalline;
    draw fullcircle scaled 2inv_rad shifted z1;
    pickup pensquare scaled normalline;
    draw z0--z4;
  endchar;
  beginchar(fc+3,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8--z9;
    pickup pensquare scaled normalline;
    draw z0--z1;
    pickup pencircle scaled normalline;
    draw z3--z2--z5;
  endchar;
enddef;

def midsegs(expr fc, myht, mydp) =
  beginchar(fc+0,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8;
  endchar;
  beginchar(fc+1,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8;
    pickup pensquare scaled normalline;
    draw z0--z1;
  endchar;
  beginchar(fc+2,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z5;
    draw z3--z8;
    pickup pencircle scaled thickline;
    draw fullcircle scaled 2inv_rad shifted z1;
    pickup pensquare scaled normalline;
    draw z0--z4;
  endchar;
  beginchar(fc+3,pin_lt#+ios_wd#,myht,mydp);
    pickup pensquare scaled thickline;
    segment
    draw z6--z8;
    pickup pensquare scaled normalline;
    draw z0--z1;
    pickup pencircle scaled normalline;
    draw z3--z2--z5;
  endchar;
enddef;


"obere Segmente Eing"&ditto&"ange";
topbotsegs(0,out_spc#,.5pin_spc#);

"obere Segmente Ausg"&ditto&"ange";
{{
  addTF(reflectedabout((.5(ios_wd+pin_lt),0),(.5(ios_wd+pin_lt),1)));
  topbotsegs(16,out_spc#,.5pin_spc#);
}}

"mittlere Segmente Eing"&ditto&"ange";
midsegs(32,.5pin_spc#,.5pin_spc#);

"mittlere Segmente Eing"&ditto&"ange";
{{
  addTF(reflectedabout((.5(ios_wd+pin_lt),0),(.5(ios_wd+pin_lt),1)));
  midsegs(48,.5pin_spc#,.5pin_spc#);
}}

"untere Segmente Eing"&ditto&"ange";
{{
  addTF(reflectedabout(left,right));
  topbotsegs(64,.5pin_spc#,out_spc#);
}}

"untere Segmente Ausg"&ditto&"ange";
{{
  addTF(reflectedabout(left,right));
  addTF(reflectedabout((.5(ios_wd+pin_lt),0),(.5(ios_wd+pin_lt),1)));
  topbotsegs(80,.5pin_spc#,out_spc#);
}}

"oberes Zwischensegment";
beginchar(96,mid_wd#,out_spc#,.5pin_spc#);
  pickup pensquare scaled thickline;
  draw (0,out_spc)--(mid_wd,out_spc);
endchar;

"Zwischensegment";
beginchar(97,mid_wd#,.5pin_spc#,.5pin_spc#);
endchar;

"unteres Zwischensegment";
beginchar(98,mid_wd#,.5pin_spc#,out_spc#);
  pickup pensquare scaled thickline;
  draw (0,-out_spc)--(mid_wd,-out_spc);
endchar;


"Gatter: Eingang, Ausgang";
beginchar(128,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z6--z8--z9--z7--cycle;
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z10--z25;
endchar;

"Gatter: Eingang negiert, Ausgang";
beginchar(129,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z3--z6--z8--z9--z7--z5;
  pickup pencircle scaled thickline;
  draw fullcircle scaled 2inv_rad shifted z1;
  pickup pensquare scaled normalline;
  draw z0--z4;
  draw z10--z25;
endchar;

"Gatter: Eingang, Ausgang negiert";
beginchar(130,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z14--z9--z7--z6--z8--z12;
  pickup pencircle scaled thickline;
  draw fullcircle scaled 2inv_rad shifted z10;
  pickup pensquare scaled normalline;
  draw z0--z1;
  draw z11--z25;
endchar;

"Gatter: zwei Eing"&ditto&"ange, Ausgang";
beginchar(131,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z6--z8--z9--z7--cycle;
  pickup pensquare scaled normalline;
  draw z15--z26;
  draw z20--z27;
  draw z10--z25;
endchar;

"Gatter: zwei Eing"&ditto&"ange, Ausgang negiert";
beginchar(132,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z14--z9--z7--z6--z8--z12;
  pickup pencircle scaled thickline;
  draw fullcircle scaled 2inv_rad shifted z10;
  pickup pensquare scaled normalline;
  draw z15--z26;
  draw z20--z27;
  draw z11--z25;
endchar;

"Gatter alt AND: zwei Eing"&ditto&"ange, Ausgang";
beginchar(133,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z1--z6{right}..z10{down}..{left}z7--cycle;
  pickup pensquare scaled normalline;
  draw z15--z26;
  draw z20--z27;
  draw z10--z25;
endchar;

"Gatter alt NAND: zwei Eing"&ditto&"ange, Ausgang";
beginchar(134,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z1--z6{right}..z10{down}..{left}z7--cycle;
  pickup pensquare scaled normalline;
  draw z15--z26;
  draw z20--z27;
  draw z10--z25;
  pickup pencircle scaled 2inv_rad;
  drawdot z10;
endchar;

"Gatter alt OR: zwei Eing"&ditto&"ange, Ausgang";
beginchar(135,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  z30=5[z26,z15];
  z31=5[z27,z20];
  z32= (z26--z30) intersectionpoint (z6{right}..{down}z10);
  z33= (z27--z31) intersectionpoint (z10{down}..{left}z7);
  pickup pensquare scaled thickline;
  draw z1--z6{right}..z10{down}..{left}z7--cycle;
  pickup pensquare scaled normalline;
  draw z26--z32;
  draw z27--z33;
  draw z10--z25;
endchar;

"Gatter alt NOR: zwei Eing"&ditto&"ange, Ausgang";
beginchar(136,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  z30=5[z26,z15];
  z31=5[z27,z20];
  z32= (z26--z30) intersectionpoint (z6{right}..{down}z10);
  z33= (z27--z31) intersectionpoint (z10{down}..{left}z7);
  pickup pensquare scaled thickline;
  draw z1--z6{right}..z10{down}..{left}z7--cycle;
  pickup pensquare scaled normalline;
  draw z26--z32;
  draw z27--z33;
  draw z10--z25;
  pickup pencircle scaled 2inv_rad;
  drawdot z10;
endchar;

"Gatter alt EQ: zwei Eing"&ditto&"ange, Ausgang";
beginchar(137,gat_lt#,.5gat_ht#,.5gat_ht#);
  gate;
  pickup pensquare scaled thickline;
  draw z1--z6{right}..z10{down}..{left}z7--cycle;
  pickup pensquare scaled normalline;
  draw z15--z26;
  draw z20--z27;
  draw z10--z25;
  x30=x31=x34=.2[x2,x13];
  y30=.7[y16,y2]; y30=y32;
  y31=.7[y21,y2]; y31=y33;
  x32=x33=x35=.8[x2,x13];
  y35=y34=y2;
  pickup pencircle scaled normalline;
  draw z30--z32;
  draw z31--z33;
  draw z34--z35;
endchar;

"box symbol empty";
beginchar(250,box_wd#,.5box_wd#,.5box_wd#);
  z0=(0,0);
  x0=x1=x2; x3=x4;
  y0=.5[y2,y1];
  y1=y3; y2=y4;
  y2-y1=x3-x1=box_wd;
  pickup pensquare scaled thickline;
  draw z1--z2--z4--z3--cycle;
endchar;

"box symbol cutted by line";
beginchar(251,box_wd#,.5box_wd#,.5box_wd#);
  z0=(0,0);
  x0=x1=x2; x3=x4;
  y0=.5[y2,y1];
  y1=y3; y2=y4;
  y2-y1=x3-x1=box_wd;
  pickup pensquare scaled thickline;
  draw z1--z2--z4--z3--cycle;
  pickup pencircle scaled normalline;
  draw z1--z4;
endchar;

"Black Box analog";
beginchar(252,bba_wd#,.5bba_ht#,.5bba_ht#);
  z0=(0,0); x1=x0=x2;
  z0=.5[z1,z2];
  y1-y2=y3-y4=bba_ht;  y1=y3;
  x3=x4=x0+bba_wd;
  pickup pensquare scaled thickline;
  draw z1--z2--z4--z3--cycle;
endchar;

"Black Box digital";
beginchar(253,bbd_wd#,.5bbd_ht#,.5bbd_ht#);
  z0=(0,0); x1=x0=x2;
  z0=.5[z1,z2];
  y1-y2=y3-y4=bbd_ht;  y1=y3;
  x3=x4=x0+bbd_wd;
  pickup pensquare scaled thickline;
  draw z1--z2--z4--z3--cycle;
endchar;

"OPV";
beginchar(254,opv_lt#,opv_ht#,opv_ht#);
  charic:=opv_dis#;
  numeric pl;
  pl:=pin_lt;
  z0=(0,0);
  z1=z0+(pl,opv_dis);
  z2=z0+(pl,opv_ht);
  z3=z0+(pl+opv_frc*2opv_ht,0);
  x4=x2; y4=-y2;
  x5=x1; y5=-y1;
  z6=z1-(pl,0);
  z7=z5-(pl,0);
  z8=z0+(opv_lt,0);
  z9=z5+(3pt,0);
  z10=z9+(4pt,0);
  z11=z1+(3pt,0);
  z12=z11+(4pt,0);
  z13=z11+(2pt,2pt);
  z14=z11+(2pt,-2pt);
  pickup pensquare scaled thickline;
  draw z2--z3--z4--cycle;
  pickup pensquare scaled normalline;
  draw z9--z10;
  draw z11--z12;
  draw z13--z14;
  draw z6--z1;
  draw z7--z5;
  draw z3--z8;
endchar;

"OPV";
beginchar(255,opv_lt#,opv_ht#,opv_ht#);
  charic:=opv_dis#;
  numeric pl;
  pl:=pin_lt;
  z0=(0,0);
  z1=z0+(pl,opv_dis);
  z2=z0+(pl,opv_ht);
  z3=z0+(pl+opv_frc*2opv_ht,0);
  x4=x2; y4=-y2;
  x5=x1; y5=-y1;
  z6=z1-(pl,0);
  z7=z5-(pl,0);
  z8=z0+(opv_lt,0);
  z9=z1+(3pt,0);
  z10=z9+(4pt,0);
  z11=z5+(3pt,0);
  z12=z11+(4pt,0);
  z13=z11+(2pt,2pt);
  z14=z11+(2pt,-2pt);
  pickup pensquare scaled thickline;
  draw z2--z3--z4--cycle;
  pickup pensquare scaled normalline;
  draw z9--z10;
  draw z11--z12;
  draw z13--z14;
  draw z6--z1;
  draw z7--z5;
  draw z3--z8;
endchar;

end;
%</csycirc>
%
%<*indexhlp>
If you want to generate an index for the circ-package please
run "makeindex" with the style-file "circ.ist" on "circ.idx".

Using EM-TeX the command line is: makeindx -s circ.ist circ.idx

To get the right pagenumbers in the index and the table of
contents, run LaTeX on "circ.drv" and makeindex in the following
way:

latex circ.drv
makeindx -s circ.ist circ.idx
latex circ.drv
makeindx -s circ.ist circ.idx
latex circ.drv
%</indexhlp>
