Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/lib/texmf/tex/generic/texdraw/blockdiagram.tex

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


% Block diagrams in TeXdraw

% $Id: blockdiagram.tex,v 1.11 1995/08/24 texdraw-V2R0 $

%   Copyright (C) 1993  Peter Kabal

% The routines in this file are provided free of charge without
% warranty of any kind.  Note that the TeXdraw routines are copyrighted.
% They may be distributed freely provided that the recipients also
% acquire the right to distribute them freely.  The notices to this
% effect must be preserved when the files are distributed.

%  Peter Kabal
%  Department of Electrical Engineering
%  McGill University
%  3480 University
%  Montreal, Quebec
%  Canada  H3A 2A7

%  kabal@TSP.EE.McGill.CA
 
% ===============================================================

\input txdtools

% size of sum and product circles
\def\cradius{0.08}

% \bdot
% big dot
\def\bdot{\fcir f:0 r:0.02 }

% centred, stacked items
\def\hcp#1{$\vcenter{\halign{\hss ##\hss\cr #1\crcr}}$}

% left justified, stacked items
\def\hlp#1{$\vcenter{\halign{##\hss\cr #1\crcr}}$}

% right justified, stacked items
\def\hrp#1{$\vcenter{\halign{\hss ##\cr #1\crcr}}$}

% signal labels - Top text, Bottom text, Left text, Right text,
% and Center text
\def\Ttext#1{\bsegment
               \textref h:C v:B  \htext (0 +0.06){\hcp{#1}}
             \esegment}
\def\Btext#1{\bsegment
               \textref h:C v:T  \htext (0 -0.06){\hcp{#1}}
             \esegment}
\def\Ltext#1{\bsegment
               \textref h:R v:C  \htext (-0.06 0){\hrp{#1}}
             \esegment}
\def\Rtext#1{\bsegment
               \textref h:L v:C  \htext (+0.06 0){\hlp{#1}}
             \esegment}
\def\Ctext#1{\bsegment
               \textref h:C v:C  \htext{\hcp{#1}}
             \esegment}

% ruled box (horizontal) with centered label,
% position set to the end of the box
% \Fbox W H text
\def\Fbox#1#2#3{\bsegment
                  \bsegment
                    \setsegscale 0.5
                    \textref h:C v:C  \htext (#1 0){\hcp{#3}}
                  \esegment
                  \setsegscale 0.5 \lvec (0 #2)
                  \setsegscale 1
                  \rlvec (#1 0) \rlvec (0 -#2) \rlvec (-#1 0) \lvec (0 0)
                  \savepos (#1 0)(*@x *@y)
                \esegment
                \move (*@x *@y)}

% ruled box (vertical) with centered label, position set to the end of the box
% \Gbox W H text
\def\Gbox#1#2#3{\bsegment
                  \bsegment
                    \setsegscale 0.5
                    \textref h:C v:C  \htext (0 #2){\hcp{#3}}
                  \esegment
                  \setsegscale 0.5 \lvec (#1 0)
                  \setsegscale 1
                  \rlvec (0 #2) \rlvec (-#1 0) \rlvec (0 -#2) \lvec (0 0)
                  \savepos (0 #2)(*@x *@y)
                \esegment
                \move (*@x *@y)}

% ruled triangle (horizontal) with centered label,
% position set to the end of the box
% \Ftri W H text
\def\Ftri#1#2#3{\bsegment
                  \bsegment
                    \setsegscale 0.3333
                    \textref h:C v:C  \htext (#1 0){\hcp{#3}}
                  \esegment
                  \bsegment
                    \savepos (#1 0)(*@x *@y)
                  \esegment
                  \setsegscale 0.5 \lvec (0 #2)
                  \setsegscale 1   \lvec (#1 0)
                  \setsegscale 0.5 \lvec (0 -#2) \lvec (0 0)
                \esegment
                \move (*@x *@y)}

% \pluss
% plus sign
\def\pluss {\bsegment
              \setsegscale {\cradius}
              \move (-0.5 0) \lvec (+0.5 0)
              \move (0 -0.5) \lvec (0 +0.5)
            \esegment}

% \minuss
% minus sign
\def\minuss {\bsegment
               \setsegscale {\cradius}
               \move (-0.5 0) \lvec (+0.5 0)
             \esegment}
% \mults
% multiplication sign
\def\mults {\bsegment
              \setsegscale {\cradius}
              \realmult \cradius {0.354} \tmpa
              \move (-0.354 -0.354) \lvec (+0.354 +0.354)
              \move (-0.354 +0.354) \lvec (+0.354 -0.354)
            \esegment}

% \pcir
% circle of given radius with a plus sign
\def\pcir {\lcir r:{\cradius}  \pluss}

% \mcir
% circle of given radius with a multiplication sign
\def\mcir {\lcir r:{\cradius}  \mults}

% \putn, \putnne, etc
% places text at an offset from the center of a circle, with
% the position of the text specified in compass directions
\def\puttext (#1 #2)#3{\bsegment
                         \setsegscale {\cradius}
                         \textref h:C v:C \htext (#1 #2){#3}
                       \esegment}
\def\putn   #1{\puttext ( 0   +2  ){#1}}
\def\putnne #1{\puttext (+1.2 +1.7){#1}}
\def\putene #1{\puttext (+1.7 +1.2){#1}}
\def\putese #1{\puttext (+1.7 -1.2){#1}}
\def\putsse #1{\puttext (+1.2 -1.7){#1}}
\def\puts   #1{\puttext ( 0   -2  ){#1}}
\def\putssw #1{\puttext (-1.2 -1.7){#1}}
\def\putwsw #1{\puttext (-1.7 -1.2){#1}}
\def\putwnw #1{\puttext (-1.7 +1.2){#1}}
\def\putnnw #1{\puttext (-1.2 +1.7){#1}}


% \avectoc
% arrow vector to a circle
\def\avectoc (#1 #2){\currentpos \xa\ya
                     \cossin ({\xa} \ya)(#1 #2)\cosa\sina
                     \savepos (#1 #2)(*@x *@y)%
                     \bsegment
                       \move (*@x *@y)%
                       \setsegscale {\cradius}
                       \rmove ({-\cosa} -\sina)%
                       \savecurrpos (*@x *@y)%
                     \esegment
                     \avec (*@x *@y)%
                     \move (#1 #2)}
% \avecfrc
% arrow vector from a circle
\def\avecfrc (#1 #2){\currentpos \xa\ya
                     \cossin ({\xa} \ya)(#1 #2)\cosa\sina
                     \bsegment
                       \setsegscale {\cradius}
                       \move ({\cosa} \sina)%
                       \savecurrpos (*@x *@y)%
                     \esegment
                     \move (*@x *@y)%
                     \avec (#1 #2)}
% \avecfrctoc
% arrow vector from a circle to a circle
\def\avecfrctoc (#1 #2){\currentpos \xa\ya
                        \cossin ({\xa} \ya)(#1 #2)\cosa\sina
                        \bsegment
                          \setsegscale {\cradius}
                          \move ({\cosa} \sina)%
                          \savecurrpos (*@x *@y)%
                        \esegment
                        \move (*@x *@y)%
                        \avectoc (#1 #2)}
% \lvecfrc
% line vector from a circle
\def\lvecfrc (#1 #2){\currentpos \xa\ya
                     \cossin ({\xa} \ya)(#1 #2)\cosa\sina
                     \bsegment
                       \setsegscale {\cradius}
                       \move ({\cosa} {\sina})%
                       \savecurrpos (*@x *@y)%
                     \esegment
                     \move (*@x *@y)%
                     \lvec (#1 #2)}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.