summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/libcct.m4
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/libcct.m4')
-rw-r--r--graphics/circuit_macros/libcct.m4139
1 files changed, 95 insertions, 44 deletions
diff --git a/graphics/circuit_macros/libcct.m4 b/graphics/circuit_macros/libcct.m4
index ed3356f4b0..d607c524fe 100644
--- a/graphics/circuit_macros/libcct.m4
+++ b/graphics/circuit_macros/libcct.m4
@@ -1,7 +1,7 @@
divert(-1)
libcct.m4
-* Circuit_macros Version 9.6, copyright (c) 2021 J. D. Aplevich under *
+* Circuit_macros Version 9.7, copyright (c) 2021 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -82,6 +82,7 @@ DEBUGGING: The statement
Arg2 chars:
[d]F or blank: flat plates; d=hatched fill
[d]C = polarized, curved plate; d=variable
+ CP = constant phase
E = polarized rectangular plates
K = filled rectangular plates
M = rectangular plates
@@ -110,6 +111,16 @@ define(`capacitor',
{line from rvec_(0,-m4cht/2) \
to rvec_(0,m4cht/2)}
line to rvec_(rp_len/2-m4cwd/2,0) ')
+ sc_draw(`dna_',CP,
+ `define(`m4cht',`ifelse(`$4',,`dimen_/3',`($4)')')dnl
+ define(`m4cwd',`ifelse(`$5',,`m4cht*0.8',`($5)')')dnl
+ line to rvec_(rp_len/2,0)
+ {line from rvec_(-m4cwd/2,m4cht/2) to Here \
+ then to rvec_(-m4cwd/2,-m4cht/2) }
+ {line from rvec_(0,m4cht/2) to rvec_(m4cwd/2,0) \
+ then to rvec_(0,-m4cht/2) }
+ line from rvec_(m4cwd/2,0) to rvec_(rp_len/2,0)
+ ')
sc_draw(`dna_',C,
`define(`m4cht',`ifelse(`$4',,`dimen_/4',`($4)')')dnl
define(`m4cwd',`ifelse(`$5',,`m4cht*0.4',`($5)')')dnl
@@ -117,7 +128,7 @@ define(`capacitor',
line to rvec_(rp_len/2-m4cwd/2,0)
{line from rvec_(0,-m4cht/2) \
to rvec_(0,m4cht/2)}
- {arc cw ifelse(m4a,d,-> wid lthick*4 ht lthick*4) \
+ {arc cw ifelse(m4a,d,-> wid lthick*4 ht lthick*5) \
from rvec_(m4cwd,-m4cht/2) \
to rvec_(m4cwd,m4cht/2) \
with .c at rvec_(m4cwd+sqrt((m4cr)^2-(m4cht/2)^2),0) }
@@ -194,29 +205,34 @@ define(`capacitor',
`resistor( linespec, cycles, chars, cycle wid)
cycles: default 3
- chars : E=ebox
- ES=ebox with slash
- Q=offset
- H=squared
- N=IEEE (default)
- B=not burnable
- V=varistor variant
- R=to right of drawing direction
+ chars : AC: complex element
+ E: ebox
+ ES: ebox with slash
+ Q: offset
+ H: squared
+ N: IEEE (default)
+ B: not burnable
+ V: varistor variant
+ R: to right of drawing direction
arg4: cycle width (default dimen_/6)'
define(`resistor',
`define(`m4h',`ifelse(`$4',,`dimen_/6',`($4)')/4')dnl
ifinstr(
- `$2',E,
+ `$2',E, # This is obsolete but kept for now
`ebox(`$1',shift(shift($@)))',
`$3',ES,
- `ebox(`$1',shift(shift(shift($@))))
- {line from last line.c+vec_(m4wd*0.3,m4ht/2) \
- to last line.c+vec_(-m4wd*0.3,-m4ht/2)}
+ `ebox(`$1')
+ {line from last line.c+vec_( m4lgth*0.3, m4wdth/2) \
+ to last line.c+vec_(-m4lgth*0.3,-m4wdth/2)}
line invis from 2nd last line.start to 2nd last line.end',
`$3',E,
- `ebox(`$1',shift(shift(shift($@))))',
+ `ebox(`$1')',
`$3',V,
`M4_varistor($@)',
+ `$3',AC,
+ `ebox(`$1')
+ { ACsymbol(at last [],m4h*3.5,m4h*2,R)
+ [] wid 2nd last [].wid ht 2nd last [].ht at 2nd last [] }',
`define(`dna_',ifelse(`$3',,N,`$3',R,N,`$3'))dnl
eleminit_(`$1')
sc_draw(`dna_',N,
@@ -360,10 +376,11 @@ define(`FTcap',`[ define(`FTctyp',`ifelse(`$1',,A,`$1')')dnl
Name1, Name2, ... if specified
ahead = blank or one of . - <- -> <-> '
define(`addtaps',`
-ifelse(`$2',,`undefine(`m4tap_x')popdef(`m4type')popdef(`m4name')',
+ifelse(`$2',,`undefine(`m4tap_x')popdef(`m4type',`m4name')',
`ifdef(`m4tap_x',`define(`m4tap_x',incr(m4tap_x))',
`define(`m4tap_x',1) M4tap_w: last [].w_; M4tap_e: last [].e_
- setkey_(`$1',type,`$1',N)setkey_(`$1',name,Tap,N)dnl
+ setkeys_(`$1',type::N; name:Tap:N)dnl
+ ifelse(m4type,,`ifinstr(`$1',=,,`define(`m4type',`$1')')')dnl
M4tap_xy: (last [].wid_,last [].ht_)')
{define(`m4tapl',`ifelse(`$3',,`dimen_/3',`$3')')dnl
move to (`$2' between M4tap_w and M4tap_e) + vec_(0,sign(m4tapl)*M4tap_xy.y/2)
@@ -443,7 +460,8 @@ define(`inductor',`eleminit_(`$1')
define(`m4n',`ifelse(`$3',,4,`$3')')dnl
ifelse(`$2',W, `define(`m4wd',((2*m4n-2)*m4c2t+2)*m4hlw)',
`$2',L, `define(`m4wd',(m4n+1)*m4hlw)',
- `define(`m4ht',`ifelse(`$2',,`dimen_/16',`$2')')define(`m4wd',m4n*m4ht*2)')
+ `define(`m4ht',`ifelse(`$5',,`dimen_/16',(`$5')/2)')dnl
+ define(`m4wd',m4n*m4ht*2)')dnl
{ line to rvec_((rp_len-m4wd)/2,0)
ifelse(`$2',W,`m4Ibody', `$2',L,`m4Lbody', `m4ibody') with .S at Here
line from last [].E to last [].E+vec_((rp_len-m4wd)/2,0) }
@@ -563,23 +581,42 @@ define(`delay',`eleminit_(`$1')
{ [box invis ht_ m4ht wid_ m4wd ] at rvec_(rp_len/2,0)}
line to rvec_(rp_len,0) invis ')
- `crystal xtal( linespec )'
-define(`xtal',`eleminit_(`$1')
- define(`m4ht',`dimen_/4')define(`m4wd',`m4ht*2/3')define(`m4cs',`m4ht/3')dnl
+ `xtal( linespec, keys ) (2-terminal crystal)
+ keys:
+ type=N (default) or R (round);
+ type N keys:
+ lgth=expr; (body length)
+ wdth=expr; (body width)
+ bxwd=expr; (body inner box width)
+ box= box attributes; (shaded ...)
+ type R keys:
+ outerdiam=expr;
+ innerdiam=expr;
+ outer= outer circle attributes; (dotted ...)
+ inner= inner circle attributes; (shaded ...)'
+define(`xtal',`eleminit_(`$1') setkey_(`$2',type,N,N)
+ ifelse(m4type,R,`setkeys_(`$2',`outerdiam:dimen_/3; innerdiam:m4outerdiam*0.4;
+ outer::N; inner::N') define(`m4wd',m4outerdiam) ',
+ `setkeys_(`$2',`wdth:dimen_/4; lgth:m4wdth*2/3; bxwd:m4lgth/2; box::N;')dnl
+ define(`m4wd',m4lgth) ')
{ line to rvec_(rp_len/2-m4wd/2,0)
- {line from rvec_(0,-m4ht/3) \
- to rvec_(0,m4ht/3)}
- { move to rvec_(m4wd/2-m4cs/2,0)
- line to rvec_(0,m4ht/2) \
- then to rvec_(m4cs,m4ht/2) \
- then to rvec_(m4cs,-m4ht/2) \
- then to rvec_(0,-m4ht/2) \
- then to Here }
- move to rvec_(m4wd,0)
- {line from rvec_(0,-m4ht/3) \
- to rvec_(0,m4ht/3)}
- line to rvec_(rp_len/2-m4wd/2,0) }
- {[box invis ht_ m4ht wid_ m4wd ] at rvec_(rp_len/2,0)}
+ {[ Orig: Here; ifelse(m4type,R,
+ `{circle diam m4outerdiam at rvec_(m4outerdiam/2,0) m4outer}
+ {circle diam m4innerdiam at rvec_(m4outerdiam/2,0) m4inner}
+ popdef(`m4type',`m4outerdiam',`m4innerdiam',`m4outer',`m4inner') ',
+ `{line from rvec_(0,-m4wdth/3) \
+ to rvec_(0,m4wdth/3)}
+ { move to rvec_(m4lgth/2-m4bxwd/2,0)
+ line to rvec_(0,m4wdth/2) \
+ then to rvec_(m4bxwd,m4wdth/2) \
+ then to rvec_(m4bxwd,-m4wdth/2) \
+ then to rvec_(0,-m4wdth/2) \
+ then to Here m4box }
+ move to rvec_(m4lgth,0)
+ {line from rvec_(0,-m4wdth/3) \
+ to rvec_(0,m4wdth/3)}
+ popdef(`m4type',`m4wdth',`m4lgth',`m4bxwd',`m4box')') ] with .Orig at Here}
+ line from rvec_(m4wd,0) to rvec_(rp_len/2+m4wd/2,0) }
line to rvec_(rp_len,0) invis ')
`source( linespec,
@@ -827,17 +864,31 @@ define(`battery',`ifelse(`$3',R,
{[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)}
line to rvec_(rp_len,0) invis ')')
- `ebox(linespec, length, ht, greyvalue)
- Box element; length and ht are relative to
+ `ebox(linespec, length, ht, greyvalue,
+ box attributes)
+ Length and ht (of the elemet) are relative to
the direction of linespec'
+ Alternative:
+ `ebox(linespec, keys)
+ keys:
+ lgth=expr; wdth=expr;
+ text="centered text";
+ box=box attributes, e.g. shaded "green"'
define(`ebox',`eleminit_(`$1')
- define(`m4wd',ifelse(`$2',,`dimen_/2',`($2)'))dnl
- define(`m4ht',ifelse(`$3',,`dimen_/5',`($3)'))dnl
- {line to rvec_(max(0,rp_len/2-m4wd/2),0)
- ifelse(`$4',,`lbox(m4wd,m4ht)',`m4fshade(`$4',lbox(m4wd,m4ht))')
- line to rvec_(max(0,rp_len/2-m4wd/2),0)}
- {[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,0)}
- line to rvec_(rp_len,0) invis ')
+ {ifinstr(`$2',=,
+ `setkeys_(`$2',`lgth:dimen_/2; wdth:dimen_/5; text::N; box::N;')
+ line to rvec_(max(0,rp_len/2-m4lgth/2),0); M4ebC: rvec_(m4lgth/2,0)
+ lbox(m4lgth,m4wdth,m4box)
+ ifelse(m4text,,,`{m4text at M4ebC};')',
+ `define(`m4lgth',`ifelse(`$2',,dimen_/2,`$2')')dnl
+ define(`m4wdth',`ifelse(`$3',,dimen_/5,`$3')')dnl
+ line to rvec_(max(0,rp_len/2-m4lgth/2),0)
+ ifelse(`$4',,`lbox(m4lgth,m4wdth,`$5')',
+ `m4fshade(`$4',lbox(m4lgth,m4wdth,`$5'))')')
+ line to rvec_(max(0,rp_len/2-m4lgth/2),0)}
+ {[ box invis ht_ m4wdth wid_ m4lgth ] at rvec_(rp_len/2,0)}
+ ifinstr(`$2',=,`popdef(`m4lgth',`m4wdth',`m4text',`m4box')')dnl
+ line to rvec_(rp_len,0) invis ')
`fuse( linespec, chars, wid, ht )
chars dA|B|C|D|S|SB|HB|HC or dA (=D)'
@@ -3413,7 +3464,7 @@ define(`Ysymbol',`[ sq3 = sqrt(3)
then to vec_(vscal_(m4size,1/sq3,-1)) }
ifelse(m4type,,,`line right_ m4size*3/2; corner
pushdef(`dimen_',m4size*4) ground popdef(`dimen_') ')
- `$4'; resetdir_ ] ifelse(`$1',,`at Here',`$1')')
+ `$4'; resetdir_ popdef(`m4size',`m4type') ] ifelse(`$1',,`at Here',`$1')')
`DCsymbol(at position, len, ht, U|D|L|R|degrees)
Arg4: drawing direction (default: current direction)'