diff options
author | Norbert Preining <norbert@preining.info> | 2023-03-12 03:01:58 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-03-12 03:01:58 +0000 |
commit | b3d8df92a44aa1df24a0869d728b45b0baeaa54c (patch) | |
tree | e29b1629fe0120f4d75acc0c72e9470ba7587b88 /graphics/circuit_macros/libcct.m4 | |
parent | 6d29701d91e7deb368e3829e1ff11dcf483cd2fb (diff) |
CTAN sync 202303120301
Diffstat (limited to 'graphics/circuit_macros/libcct.m4')
-rw-r--r-- | graphics/circuit_macros/libcct.m4 | 266 |
1 files changed, 192 insertions, 74 deletions
diff --git a/graphics/circuit_macros/libcct.m4 b/graphics/circuit_macros/libcct.m4 index 3a3e1f398a..cf73ba0567 100644 --- a/graphics/circuit_macros/libcct.m4 +++ b/graphics/circuit_macros/libcct.m4 @@ -1,7 +1,7 @@ divert(-1) libcct.m4 -* Circuit_macros Version 10.1, copyright (c) 2022 J. D. Aplevich under * +* Circuit_macros Version 10.2, copyright (c) 2023 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 * @@ -1070,40 +1070,71 @@ define(`pvcell',`eleminit_(`$1') move to rvec_(m4wd,0); line to rvec_(max(0,rp_len/2-m4wd/2),0) } line invis to rvec_(rp_len,0)') - `heater( linespec, nparts, wid, ht )' -define(`heater',`eleminit_(`$1') - define(`m4hn',ifelse(`$2',,4,`$2'))dnl - define(`m4wd',ifelse(`$3',,`dimen_/2',`($3)'))dnl - define(`m4ht',ifelse(`$4',,`dimen_/5',`($4)'))dnl - { line to rvec_(max(0,rp_len/2-m4wd/2),0) - {[lbox(m4wd,m4ht)] at rvec_(m4wd/2,0)} - for m4ix=1 to m4hn-1 do { - {line from rvec_(m4ix*m4wd/(m4hn),m4ht/2) \ - to rvec_(m4ix*m4wd/(m4hn),-m4ht/2)}} - line from rvec_(m4wd,0) \ - to rvec_(max(0,rp_len/2+m4wd/2),0) } - line invis to rvec_(rp_len,0)') - - `thermocouple(linespec, wid, ht, L|R) - R=right orientation' -define(`thermocouple',`eleminit_(`$1') - define(`m4wd',ifelse(`$2',,`dimen_/5',`($2)'))dnl - define(`m4ht',ifelse(`$3',,`dimen_/2',`($3)'))dnl - define(`m4ths',`ifinstr(`$4',R,-)')dnl - {line to rvec_(max(0,rp_len/2-m4wd/2),0) \ - then to rvec_(max(0,rp_len/2-m4wd/2),m4ths`'(m4ht-m4wd/2)) \ - then to rvec_(rp_len/2,m4ths`'m4ht) \ - then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,m4ths`'(m4ht-m4wd/2)) \ - then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,0) \ - then to rvec_(rp_len,0)} - { dot(at rvec_(rp_len/2,m4ths`'m4ht)) } - {[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,m4ths`'m4ht/2)} - line to rvec_(rp_len,0) invis ') - - `lamp(linespec,[R])' -define(`lamp',`define(`m4ng',ifinstr(`$2',R,-))define(`m4hw',`dimen_/10')dnl -define(`m4dp',(m4ng`'m4hw/2))define(`m4ht',(m4ng`'dimen_/8))dnl -eleminit_(`$1') + `heater( linespec, nparts|keys, wid, ht, + boxspec|[E[R][T]] ) + If arg5 contains E, draws an + heatere(linespec,keys,[R][T]) otherwise a + heatert(linespec,nparts,wid,ht,boxspec)' +define(`heater',`ifinstr(`$5',E, + `heatere(`$1',`$2',`$5')', + `heatert($@)')') + + `heatere( linespec, keys, [R|T] ) + R: right orientation + T: truncates leads to the width of the body + keys: (for body) + lgth=expr; + wdth=expr; (default lgth*2/5) + cycles=expr; + line=attributes' +define(`heatere', +`pushkeys_(`$2',`lgth:dimen_/2; wdth:m4lgth*2/5; cycles:3; line::N;')dnl + ifinstr(`$3',R,`pushdef(`m4ng',-)pushdef(`m4cw')pushdef(`m4ccw',cw)', + `pushdef(`m4ng') pushdef(`m4cw',cw)pushdef(`m4ccw')')dnl + eleminit_(ifinstr(`$3',T,m4wdth,`$1')) + { line to rvec_(rp_len/2-m4wdth/2,0); round + {[S: Here; r = m4lgth/(4*m4cycles+1) + arc m4cw m4line to rvec_(r,m4ng`'r) with .c at rvec_(r,0) + for i=1 to m4cycles do { arc m4ccw m4line to rvec_(0,m4ng`'2*r) \ + with .c at rvec_(0,m4ng`'r) + arc m4cw m4line to rvec_(0,m4ng`'2*r) with .c at rvec_(0,m4ng`'r) } + line m4line to rvec_(m4wdth-2*r,0) + for i=1 to m4cycles do {arc m4cw m4line to rvec_(0,m4ng`'(-2*r)) \ + with .c at rvec_(0,m4ng`'(-r)) + arc m4ccw m4line to rvec_(0,m4ng`'(-2*r)) with .c at rvec_(0,m4ng`'(-r)) } + arc m4cw m4line to rvec_(r,m4ng`'(-r)) with .c at rvec_(0,m4ng`'(-r)); round + ] with .S at Here } + line from rvec_(m4wdth,0) to rvec_(rp_len/2+m4wdth/2,0) } + line invis to rvec_(rp_len,0)dnl + popdef(`m4lgth',`m4wdth',`m4cycles',`m4line',`m4ng',`m4cw',`m4ccw') ') + + `heatert(linespec, nparts|keys, wid,ht,boxspec) + keys: parts=expr; + lgth=expr; + wdth=expr; + box=attributes; + args 3-5 unused if any key is given + arg5= body attributes' +define(`heatert',`eleminit_(`$1') + ifelse(regexp(`$2',`parts=\|lgth=\|wdth=\|box='),-1, dnl not very elegant + `pushdef(`m4parts',ifelse(`$2',,4,`$2'))dnl + pushdef(`m4lgth',ifelse(`$3',,`dimen_/2',`($3)'))dnl + pushdef(`m4wdth',ifelse(`$4',,`dimen_/5',`($4)'))dnl + pushdef(`m4box',`$5')', + `pushkeys_(`$2',`parts:4; lgth:dimen_/2; wdth:dimen_/5; box::N')')dnl + { line to rvec_(max(0,rp_len/2-m4lgth/2),0) + {[lbox(m4lgth,m4wdth,m4box)] at rvec_(m4lgth/2,0)} + for m4ix=1 to m4parts-1 do { + {line from rvec_(m4ix*m4lgth/(m4parts),m4wdth/2) \ + to rvec_(m4ix*m4lgth/(m4parts),-m4wdth/2) m4box}} + line from rvec_(m4lgth,0) \ + to rvec_(max(0,rp_len/2+m4lgth/2),0) } + line invis to rvec_(rp_len,0) popdef(`m4parts',`m4lgth',`m4wdth',`m4box')') + + `lamp(linespec,[R][T])' +define(`lamp',`pushdef(`m4ng',`ifinstr(`$2',R,-)')pushdef(`m4hw',`dimen_/10')dnl +pushdef(`m4dp',(m4ng`'m4hw/2))pushdef(`m4ht',(m4ng`'dimen_/8))dnl +eleminit_(ifinstr(`$2',T,m4hw*2,`$1')) { line to rvec_(rp_len/2-m4hw,0) \ then to rvec_(rp_len/2-m4hw,m4ng`'dimen_/3.2) spline ifdpic(ctension_) to rvec_(0,m4ht) \ @@ -1116,7 +1147,24 @@ eleminit_(`$1') line to rvec_(0,-(m4ng`'dimen_/3.2)) \ then to rvec_(rp_len/2-m4hw,-(m4ng`'dimen_/3.2)) } { [ circle rad dimen_/5 ] at rvec_(rp_len/2,m4ng`'dimen_/3.2) } - line invis to rvec_(rp_len,0) ') + line invis to rvec_(rp_len,0) popdef(`m4ng',`m4hw',`m4dp',`m4ht') ') + + `thermocouple(linespec, wid, ht, L|R [T]) + T=truncated leads; + R=right orientation' +define(`thermocouple',`pushdef(`m4wd',ifelse(`$2',,`dimen_/5',`($2)'))dnl + eleminit_(ifinstr(`$4',T,m4wd,`$1')) + pushdef(`m4ht',ifelse(`$3',,`dimen_/2',`($3)'))dnl + pushdef(`m4ths',`ifinstr(`$4',R,-)')dnl + {line to rvec_(max(0,rp_len/2-m4wd/2),0) \ + then to rvec_(max(0,rp_len/2-m4wd/2),m4ths`'(m4ht-m4wd/2)) \ + then to rvec_(rp_len/2,m4ths`'m4ht) \ + then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,m4ths`'(m4ht-m4wd/2)) \ + then to rvec_(max(0,rp_len/2-m4wd/2)+m4wd,0) \ + then to rvec_(rp_len,0)} + { dot(at rvec_(rp_len/2,m4ths`'m4ht)) } + {[box invis ht_ m4ht wid_ m4wd] at rvec_(rp_len/2,m4ths`'m4ht/2)} + line to rvec_(rp_len,0) invis popdef(`m4wd',`m4ht',`m4ths')') `cbreaker( linespec, L|R, D|Th|TS, body name ) circuit breaker to left or right of linespec, @@ -1164,6 +1212,45 @@ define(`mbreaker',`eleminit_(`$1') define(`m4R',`ifelse(`$2',R,-)') wid_ m4h+dimen_/16] at rvec_(m4h/2,m4R`'(m4ht/2)) } line to rvec_(rp_len,0) invis ') + `jumper(linespec,chars|keys) + Two-terminal solder jumper with named body parts. + chars: character sequence normally beginning + with C and ending with D specifying the jumper + components and their attribs: C is first, D last, + E is empty (blank) gap, J is filled gap, B is + box component. + The components are named T1, T2, ... + e.g. CED is a simple open jumper (default); + CJD closed; CEBED three-contact open; + CJBED three-contact open and closed. + keys: + type=chars as above; + body=attributes; (e.g. fill_(0.5)) + wdth=expr; + name=chars; body name' +define(`jumper',`eleminit_(`$1') + pushkeys_(`$2',`type:m4typ:N; body:fill_(0):N; wdth:dimen_/5; name::N;')dnl + ifelse(m4type,m4typ, + `poppushdef(`m4type',`ifelse(`$2',,CED,`ifinstr(`$2',=,CED,`$2')')')')dnl + pushdef(`m4r',m4wdth/2) pushdef(`m4lgth',`m4r*len(m4type)')dnl + { line to rvec_(rp_len/2-m4lgth/2,0) + { line from rvec_(m4lgth,0) to rvec_(rp_len/2+m4lgth/2,0) } + {ifelse(m4name,,,m4name:) [ S: Here + for_(1,len(m4type),1,`define(`m4ch',`substr(m4type,decr(m4x),1)')dnl + T`'m4x: ifelse(m4ch,C, + `[ arc to rvec_(0,-m4wdth) with .c at rvec_(0,-m4r) m4body + round(,,m4body); L: line to rvec_(0,m4wdth) m4body; round(,,m4body) + ] with .L.c at rvec_(m4r,0); move to last [].L.c ', + m4ch,J,`rotbox(m4r,m4r,m4body)', + m4ch,B,`rotbox(m4r,m4wdth,m4body)', + m4ch,E,`move to rvec_(m4r,0)', + m4ch,D,`[ arc to rvec_(0,m4wdth) with .c at rvec_(0,m4r) m4body + round(,,m4body); L: line to rvec_(0,-m4wdth) m4body; round(,,m4body) + ] with .L.c at Here; move to T`'m4x.L.c+vec_(m4r,0)')') + ] with .S at Here } } + line invis to rvec_(rp_len,0) undefine(`m4ch') dnl + popdef(`m4type',`m4body',`m4wdth',`m4name',`m4r',`m4lgth') ') + `gap( linespec,fill,A ) Gap with filled dots e.g. gap(down_ linewid/2,1); rlabel(+,v_1,-) @@ -1986,9 +2073,8 @@ define(`m4gen_d',`{dnl sep=expr; arrow separation angle=degrees; absolute direction' define(`em_arrows',`[ - pushkeys_(`$1',`type:m4nul:N; angle:ifelse(`$2',,135,`($2)')*dtor_')dnl - ifelse(m4type,m4nul, - `popdef(`m4type')pushdef(`m4type',`ifelse(`$1',,N,`$1')')')dnl + pushkeys_(`$1',`type:m4typ:N; angle:ifelse(`$2',,135,`($2)')*dtor_')dnl + ifelse(m4type,m4typ,`poppushdef(`m4type',`ifelse(`$1',,N,`$1')')')dnl arrowhead = em_arrowhead sc_draw(`m4type',N, `pushkeys_(`$1',lgth:ifelse(`$3',,dimen_*0.46,`$3'); sep:em_arrowwid*9/8)dnl @@ -3201,37 +3287,67 @@ define(`ccoax',`[define(`m4cd',ifelse(`$3',,`dimen_*0.4',`$3'))dnl C: circle diam m4cd/3 fill_(ifinstr(`$2',F,1,0)) at S `$4'] with .c ifelse(`$1',,`at Here',`$1')') - `tconn( linespec, >|>>|<|<<|O[F], wid) - terminal connector - O=node (circle); OF=filled circle - > (default) or >> =output - < or << =input - arg3 is arrowhead width or circle diam' + `tconn( linespec, chars|keys, wid) + terminal connector with head in a [] block + chars: + O=node (circle); OF=filled circle + > (default) | >> | < | << | A | AA | M + A or AA signify arc or double arc + M signifies male bar contact + arg3 is head width or circle diam + keys: + type=chars as above; + wdth=expr; head width; + lgth=expr; type M head length; + sep=expr; double head separation + head=attributes; except lgth, wdth' define(`tconn', - `define(`m4ph',`ifelse(`$3',,`dimen_/6',`($3)/2')')dnl - define(`m4ps',`dimen_/8') define(`m4cd',`ifelse(`$3',,`dimen_/5',`$3')')dnl - eleminit_(`$1',dimen_*3/4) - M4Ss: last line.start; M4Se: last line.end - ifelse(ifinstr(`$2',0,O,`$2'),O, - `{circle diam m4cd ifinstr(`$2',OF,`fill_(0)') ifinstr(`$2',0F,`fill_(0)') \ - at (m4cd)/2/distance(M4Ss,M4Se) between M4Se and M4Ss} - {line to last line.end chop 0 chop m4cd}', - `$2',<<, - `{line to last line.end chop 0 chop m4ps+m4ph - {line from rvec_(m4ph,m4ph) to Here then to rvec_(m4ph,-m4ph)} - move to rvec_(m4ps,0) - line from rvec_(m4ph,m4ph) to Here then to rvec_(m4ph,-m4ph)}', - `$2',<, - `{line to last line.end chop 0 chop m4ph - line from rvec_(m4ph,m4ph) to Here then to rvec_(m4ph,-m4ph)}', - `$2',>>, - `{line to last line.end chop 0 chop m4ps - {line from rvec_(-m4ph,m4ph) to Here then to rvec_(-m4ph,-m4ph)} - move to rvec_(m4ps,0) - line from rvec_(-m4ph,m4ph) to Here then to rvec_(-m4ph,-m4ph)}', + `pushkeys_(`$2', + `type:m4typ:N; lgth:m4nl; wdth:dimen_/6; sep:dimen_/8; head::N') + ifelse(m4type,m4typ,`poppushdef(`m4type',ifelse(`$2',,>,`$2'))')dnl + ifelse(m4lgth,(m4nl),`poppushdef(`m4lgth',ifelse(`$3',,(dimen_/2),`($3)/2'))') + eleminit_(`$1',dimen_*3/4) + M4Ss: last line.start; M4Se: last line.end + ifelse(ifinstr(m4type,0,O,`ifinstr(m4type,OF,O,m4type)'),O, + `{popdef(`m4wdth')pushdef(`m4wdth',ifelse(`$3',,dimen_/5,`$3'))dnl + line to last line.end chop 0 chop m4wdth + [circle diam m4wdth ifinstr(m4type,OF,`fill_(0)') m4head] \ + at rvec_(m4wdth/2,0)}', + m4type,AA, + `{line to last line.end chop 0 chop m4sep+m4wdth + [{A: arc from rvec_(0,m4wdth) to rvec_(0,-m4wdth) with .c at Here m4head} + arc from rvec_(m4sep,m4wdth) to rvec_(m4sep,-m4wdth) \ + with .c at rvec_(m4sep,0) m4head] with .A.c at rvec_(m4wdth,0) }', + m4type,A, + `{line to last line.end chop 0 chop m4wdth + [A:arc from rvec_(0,m4wdth) to rvec_(0,-m4wdth) with .c at Here m4head] \ + with .A.c at rvec_(m4wdth,0) }', + m4type,<<, + `{line to last line.end chop 0 chop m4sep+m4wdth + [S: Here; {line from rvec_(m4wdth,m4wdth) to S \ + then to rvec_(m4wdth,-m4wdth) m4head}; move to rvec_(m4sep,0) + line from rvec_(m4wdth,m4wdth) to Here then to rvec_(m4wdth,-m4wdth) \ + m4head ] with .S at Here }', + m4type,<, + `{line to last line.end chop 0 chop m4wdth + [S: Here; line from rvec_(m4wdth,m4wdth) to S \ + then to rvec_(m4wdth,-m4wdth) m4head] with .S at Here }', + m4type,>>, + `{line to last line.end chop 0 chop m4sep + [S: Here; {line from rvec_(-m4wdth,m4wdth) to S \ + then to rvec_(-m4wdth,-m4wdth) m4head}; move to rvec_(m4sep,0) + line from rvec_(-m4wdth,m4wdth) to Here then to rvec_(-m4wdth,-m4wdth) \ + m4head ] with .S at Here }', + m4type,M, + `{line to last line.end chop 0 chop m4lgth + [ S: Here; NW: rvec_(0,m4wdth/2); SW: rvec_(0,-m4wdth/2) + NE: rvec_(m4lgth,m4wdth/2); SE: rvec_(m4lgth,-m4wdth/2) + L: line thick 0 to NW then to NE then to SE then to SW then to Here \ + ifelse(m4head,,fill_(0),m4head) ] with .S at Here}', `{line to last line.end - line from rvec_(-m4ph,m4ph) to Here then to rvec_(-m4ph,-m4ph)}') - line invis to M4Se') + [S: Here; line from rvec_(-m4wdth,m4wdth) to S \ + then to rvec_(-m4wdth,-m4wdth) m4head ] with .S at Here }') + line invis to M4Se popdef(`m4type',`m4lgth',`m4wdth',`m4sep',`m4head') ') `tbox( text,wid,ht,<|>|<>,type ) Pointed terminal box. @@ -3497,13 +3613,15 @@ define(`ACsymbol',`[ Origin: Here pushdef(`m4amp',`ifelse(`$3',,`m4range/6',`($3)/2')')dnl for_(1,m4n,1,`move to Origin+vec_(0,((m4n+1)/2-m4x)*m4range/3) ifinstr(ifgpic(A,`$4'),A, - `{ arc ccw to rvec_(-m4range/2,0) \ - with .c at rvec_(-m4range/4,-max(m4range/4-m4amp,0)) } - { arc ccw to rvec_( m4range/2,0) \ - with .c at rvec_( m4range/4, max(m4range/4-m4amp,0)) }', - `{ sinusoid(m4amp,twopi_/m4range,pi_/2,-m4range/2,m4range/2) \ + `{ S`'m4x: [ Origin: Here + { arc ccw to rvec_(-m4range/2,0) \ + with .c at rvec_(-m4range/4,-max(m4range/4-m4amp,0)) } + { arc ccw to rvec_( m4range/2,0) \ + with .c at rvec_( m4range/4, max(m4range/4-m4amp,0)) }] dnl + with .Origin at Here }', + `{ S`'m4x: sinusoid(m4amp,twopi_/m4range,pi_/2,-m4range/2,m4range/2) dnl with .Origin at Here } ')') - `$5'; resetdir_ popdef(`m4amp',`m4n',`m4ACd',`m4range')] \ + `$5'; resetdir_ popdef(`m4amp',`m4n',`m4ACd',`m4range')] dnl with .Origin ifelse(`$1',,`at Here',`$1')') `Deltasymbol(at position, keys, U|D|L|R|degrees) |