summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/examples')
-rw-r--r--graphics/circuit_macros/examples/ASME_Y14-5.m410
-rw-r--r--graphics/circuit_macros/examples/AntiqueClock.m4145
-rw-r--r--graphics/circuit_macros/examples/Capacitors.m414
-rw-r--r--graphics/circuit_macros/examples/Crow.m43
-rw-r--r--graphics/circuit_macros/examples/Geometry.m430
-rw-r--r--graphics/circuit_macros/examples/Inductors.m45
-rw-r--r--graphics/circuit_macros/examples/IntersectingPlanes.m484
-rw-r--r--graphics/circuit_macros/examples/Makefile6
-rw-r--r--graphics/circuit_macros/examples/Metamodel.m478
-rw-r--r--graphics/circuit_macros/examples/MoreTable.m411
-rw-r--r--graphics/circuit_macros/examples/Resistors.m422
-rw-r--r--graphics/circuit_macros/examples/Rotbox.m43
-rw-r--r--graphics/circuit_macros/examples/Shaky.m445
-rw-r--r--graphics/circuit_macros/examples/birds.m42
-rw-r--r--graphics/circuit_macros/examples/control.m414
-rw-r--r--graphics/circuit_macros/examples/ex01.m48
-rw-r--r--graphics/circuit_macros/examples/examples.pdfbin893291 -> 892920 bytes
-rw-r--r--graphics/circuit_macros/examples/examples.tex6
-rw-r--r--graphics/circuit_macros/examples/files.tex55
-rw-r--r--graphics/circuit_macros/examples/mf/cct.mf2
-rw-r--r--graphics/circuit_macros/examples/squiggle.m43
-rw-r--r--graphics/circuit_macros/examples/svg/ByteSVG.m42
-rw-r--r--graphics/circuit_macros/examples/svg/CapacitorsSVG.m49
-rw-r--r--graphics/circuit_macros/examples/svg/ChipsSVG.m42
-rw-r--r--graphics/circuit_macros/examples/svg/EEPSVG.m456
-rw-r--r--graphics/circuit_macros/examples/svg/GeometrySVG.m435
-rw-r--r--graphics/circuit_macros/examples/svg/MoreTableSVG.m42
-rw-r--r--graphics/circuit_macros/examples/svg/ResistorsSVG.m430
-rw-r--r--graphics/circuit_macros/examples/svg/RotboxSVG.m45
-rw-r--r--graphics/circuit_macros/examples/svg/SLD.m4389
-rw-r--r--graphics/circuit_macros/examples/svg/SchottkySVG.m42
-rw-r--r--graphics/circuit_macros/examples/svg/ex01SVG.m48
-rw-r--r--graphics/circuit_macros/examples/svg/examplesSVG.htmx67
-rw-r--r--graphics/circuit_macros/examples/svg/tstSVG.htmx261
-rw-r--r--graphics/circuit_macros/examples/xfig/xfiglib.fig4
35 files changed, 1163 insertions, 255 deletions
diff --git a/graphics/circuit_macros/examples/ASME_Y14-5.m4 b/graphics/circuit_macros/examples/ASME_Y14-5.m4
index fbcf8eb003..00b044b093 100644
--- a/graphics/circuit_macros/examples/ASME_Y14-5.m4
+++ b/graphics/circuit_macros/examples/ASME_Y14-5.m4
@@ -138,11 +138,11 @@ define(`cdashl',0.1*scale)
define(`cgapl',0.03*scale)
define(`ctrline',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
define(`m4h',ifelse(`$2',,1*scale,`$2'))dnl
- m4n = int(rp_len/2/(m4h))*2+1
- for i=1 to m4n do {
- line to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0)
+ m4xn = int(rp_len/2/(m4h))*2+1
+ for i=1 to m4xn do {
+ line to rvec_(rp_len/m4xn/2-cdashl/2-cgapl,0)
move to rvec_(cgapl,0); line to rvec_(cdashl,0); move to rvec_(cgapl,0)
- line to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0) } ')
+ line to rvec_(rp_len/m4xn/2-cdashl/2-cgapl,0) } ')
`ctrarcr(pos,radius,startang,endang,len)
Arc cr centerline'
@@ -165,4 +165,6 @@ define(`ctrarcr',`dnl
m5sa = m5sa+m5a
} ')
+define(`ASME_Y14-5_')
+
divert(0)dnl
diff --git a/graphics/circuit_macros/examples/AntiqueClock.m4 b/graphics/circuit_macros/examples/AntiqueClock.m4
new file mode 100644
index 0000000000..c77950fe00
--- /dev/null
+++ b/graphics/circuit_macros/examples/AntiqueClock.m4
@@ -0,0 +1,145 @@
+.PS
+# AntiqueClock.m4
+gen_init
+NeedDpicTools
+# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals
+
+# `hms2deg(hr,min,sec) hr:min:sec to degrees
+# blank arg1: degrees for minute hand
+# blank arg1 and arg2: degrees for second hand'
+define(`hms2deg',`ifelse(`$1',,
+ `ifelse(`$2',,
+ `(90-pmod(ifelse(`$3',,0,`$3'),60)/60*360)',
+ `(90-(pmod(`$2',60)/60 + pmod(ifelse(`$3',,0,`$3'),60)/60/60)*360)')',
+ `(90-(pmod(`$1',12) + pmod(ifelse(`$2',,0,`$2'),60)/60 + dnl
+ pmod(ifelse(`$3',,0,`$3'),60)/3600)/12*360)')')
+
+# `SecondHand(length,hr,min,sec)'
+define(`SecondHand',`[ shsf = (`$1')/3.2
+ C: Here
+ { L: rpoint_(to (Rect_(`$1',hms2deg(,,`$4')))) }
+ line thick 8*shsf to rvec_(`$1',0)
+ ]')
+
+# `AntiqueMinuteHand(length,hr,min,sec)'
+define(`AntiqueMinuteHand',`[ mhsf = (`$1')/2.84
+ L: rpoint_(to (Rect_(`$1',hms2deg(,`$3',`$4'))))
+ C: circle fill_(0) diam 0.47*mhsf at L.start
+ move to C
+ spline from rvec_(0,0.047*mhsf) \
+ to rvec_(1.65*mhsf,0.11*mhsf) \
+ then to rvec_(`$1',0.018*mhsf) \
+ then to rvec_(`$1',-0.018*mhsf) \
+ then to rvec_(1.65*mhsf,-0.11*mhsf) \
+ then to rvec_(0,-0.047*mhsf) \
+ shaded rgbstring(0,0,0)
+ ]')
+
+# `AntiqueHourHand(length,hr,min,sec)'
+define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2
+ L: rpoint_(to (Rect_(`$1',hms2deg(`$2',`$3',`$4'))))
+ C: circle fill_(0) diam 0.6*hhsf at L.start
+ move to C
+ v = 0.25*hhsf
+ { line to rvec_(1.1*hhsf,0) thick 0.15/(1bp__)*hhsf }
+ { C1: circle rad v at rvec_(1.25*hhsf,0) fill_(0) }
+ d = `$1'-1.25*hhsf
+ q = 1bp__*hhsf
+ r1 = (d^2 + q^2 - v^2)/(v-q)/2
+ h = r1+v
+ shade(0,
+ arc ccw from C1+vec_(d/h*v,(r1+q)/h*v) to \
+ C1+vec_(d,q) rad r1 with .c at C1+vec_(d,r1+q)
+ arc ccw from C1+vec_(d,-q) to C1+vec_(d/h*v,-(r1+q)/h*v) rad r1 \
+ with .c at C1+vec_(d,-r1-q))
+ ]')
+
+define(`AntiqueClock',`[ # h,m,s,diam
+# Clock size parameters
+ # outer radius
+ hour = ifelse(`$1',,3,`$1')
+ minute = ifelse(`$2',,41,`$2')
+ second = ifelse(`$3',,51,`$3')
+ ifelse(`$4',,`skale=0.5; r1=2',`r1=(`$4')/2; skale=r1/4')
+ r2 = r1-0.5*skale
+ r3 = r2-0.14*skale
+ r4 = r3 - 0.35*skale
+ r5 = r4 - 0.17*skale
+ r6 = r5 - 0.63*skale
+ r7 = r6 - 0.17*skale
+ shadethick = 1.0
+
+C: circle thick 0.2 rad r1
+
+define shadeline {
+ s = 1-($`'1)*2
+ v = r*s
+ h = sqrt(r^2-v^2)
+ t = 1-abs(s)
+ line from (vrot_(-h,v,cost,sint)) to (vrot_(h,v,cost,sint)) \
+ thick shadethick outlined rgbstring(t,t,t)
+ }
+
+ r = r1 # Bezel outer
+ nlines = int(2*r/(shadethick pt__)*1.1)
+ cost = cosd(10); sint = sind(10);
+ ShadeObject(shadeline,nlines, 0, 0,0,0,
+ 0.5, 1,1,1,
+ 1, 0,0,0 ) at C
+
+ r = r2 # Bezel inner
+ nlines = int(2*r/(shadethick pt__)*1.1)
+ cost = cosd(-10); sint = sind(-10);
+ ShadeObject(shadeline,nlines, 0, 0,0,0,
+ 0.25, 0.8,0.8,0.8,
+ 0.5, 1,1,1,
+ 0.75, 0.8,0.8,0.8,
+ 1, 0,0,0 ) at C
+
+# Clock face
+Face: circle thick 0 fill_(1) rad r3 at C
+ circle rad r4 at C
+ circle rad r5 at C
+ circle rad r6 at C
+ circle rad r7 at C
+
+define rotext {
+sprintf("`$'1 ifpstricks(\rput[C]{%g}(0,0){%g},
+ifpgf(\rotatebox{%g}{%g}))",`$'2,`$'3) }
+# Outer numbers
+ command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4)
+ for mn = -15 to 15 by 5 do { rotext(\outerfont,-mn/60*360,pmod(mn,60)) \
+ at C+(Rect_((r3+r4)/2,90-mn/60*360)) }
+ for mn = 20 to 40 by 5 do { rotext(\outerfont,180-mn/60*360,mn) \
+ at C+(Rect_((r3+r4)/2,90-mn/60*360)) }
+# Outer tics
+ for mn = 1 to 60 do { t = 90-mn/60*360
+ line from C+(Rect_(r5,t)) to C+(Rect_(r4,t)) }
+
+# Inner numbers
+ command sprintf("\font\innerfont=cmss12 at %4.2fin",r5-r6)
+ Loopover_(`mx',`t = (m4Lx-4)/12*360;
+ sprintf("\innerfont`'ifpstricks(`\rput[C]{%g}(0,0)',
+ `\rotatebox{%g}'){\scalebox{0.7}[1.0]{mx}}",-t) \
+ at C+(Rect_((r5+r6)/2,90-t))', IX,X,XI,XII,I,II,III)
+ Loopover_(`mx',`t = (m4Lx+3)/12*360;
+ sprintf("\innerfont`'ifpstricks(`\rput[C]{%g}(0,0)',
+ `\rotatebox{%g}'){\scalebox{.7}[1.0]{mx}}",-t+180) \
+ at C+(Rect_((r5+r6)/2,90-t))', IV,V,VI,VII,VIII)
+# Inner tics
+ for mn = 5 to 60 by 5 do { t = 90-mn/60*360
+ line from C+(Rect_(r7,t)) to C+(Rect_(r6,t)) }
+
+# Hands
+ AntiqueHourHand(r6,hour,minute,second) with .C at C
+ AntiqueMinuteHand(r5,hour,minute,second) with .C at C
+ SecondHand((r3+r4)/2,hour,minute,second) with .C at C
+
+# Center
+ dot(at C,0.1/4*r1,1)
+ ]')
+
+ Clock1: AntiqueClock
+ Clock2: AntiqueClock(4,50,07,2) at Clock1.e+(1.5,0)
+
+.PE
diff --git a/graphics/circuit_macros/examples/Capacitors.m4 b/graphics/circuit_macros/examples/Capacitors.m4
index d2586f1b9b..d96a6f8827 100644
--- a/graphics/circuit_macros/examples/Capacitors.m4
+++ b/graphics/circuit_macros/examples/Capacitors.m4
@@ -1,5 +1,5 @@
.PS
-# `Capacitors.m4'
+# Capacitors.m4
cct_init
movewid = 2 pt__
@@ -23,16 +23,18 @@ vm = 0.28
move right_ hm
{capacitor(,N); move ;"`{\tt capacitor(,N)}'" ljust}
move right_ hm
- {xtal ; move ;"`{\tt xtal}'" ljust}
+ {capacitor(,CP); move ;"`{\tt capacitor(,CP)}'" ljust}
}
move down 0.25; right_
{ {capacitor(,dC); move ;"`{\tt capacitor(,dC)}'" ljust}
move right_ hm
{capacitor(,dF); move ;"`{\tt capacitor(,dF)}'" ljust}
move right_ hm
- {variable(`capacitor',NN,-30,dimen_/3)
- move ;`"{\tt variable(}`{\tt capacitor',}"' ljust \
- `"{\enskip\tt NN,-30,dimen\_/3)}"' ljust
- }
+ {variable(`capacitor',NN,-30,dimen_/3); move
+# Stacking the strings normally does not work because the .pdf uses the
+# length of the last line.
+ "`{\tt variable(}{\rm}{\tt capacitor}{\rm}{\tt,}'" ljust
+ "`{\enskip\tt NN,-30,dimen\_/3)}'" ljust at last ""+(0,-12pt__)
+ }
}
.PE
diff --git a/graphics/circuit_macros/examples/Crow.m4 b/graphics/circuit_macros/examples/Crow.m4
index 91434c0c01..23f579a452 100644
--- a/graphics/circuit_macros/examples/Crow.m4
+++ b/graphics/circuit_macros/examples/Crow.m4
@@ -8,13 +8,14 @@ sinclude(tst.dim)
# Custom macros --------------------------
# `crowline(linespec,wid,ht)'
+# `Single-segment line with crowfoot end'
define(`crowline',
`line `$1'
M4_E: last line.end
crow_wd = ifelse(`$2',,`(arrowwid*8/5)',`$2')
crow_ht = ifelse(`$3',,`(1.5*crow_wd)',`$3')
M4_P: vperp(last line,crow_wd)
- M4_X: crow_ht/lin_leng(last line) between M4_E and last line.start
+ M4_X: Along_(last line,crow_ht,R)
ifdpic(
`spline 0.4 from M4_E+M4_P to M4_X+M4_P then to M4_X-M4_P then to M4_E-M4_P',
`spline from M4_E+(M4_P.x,M4_P.y) to M4_X+(M4_P.x,M4_P.y) \
diff --git a/graphics/circuit_macros/examples/Geometry.m4 b/graphics/circuit_macros/examples/Geometry.m4
index 0cbf4bb499..771f4a6b7c 100644
--- a/graphics/circuit_macros/examples/Geometry.m4
+++ b/graphics/circuit_macros/examples/Geometry.m4
@@ -10,7 +10,7 @@ Fig1: [ ls = 2/3 # local scale
BC: line from B to C
CA: line from C to A
- PerpTo(A,BC,L); "L" at L below
+ perpto(A,BC,L); "L" at L below
AL: line from A to L; RightAngle(A,L,C)
angleLAC = atan2(C.x-L.x,A.y-L.y)
@@ -18,10 +18,10 @@ Fig1: [ ls = 2/3 # local scale
AW: line from A to Intersect_(S,BC)
W: Here; "W" at W below rjust
- PerpTo(C,AB,N); "N" at N above rjust
+ perpto(C,AB,N); "N" at N above rjust
CN: line from C to N; RightAngle(C,N,B)
- PerpTo(B,CA,M); "M" at M above
+ perpto(B,CA,M); "M" at M above
CM: line from B to M; RightAngle(B,M,C)
H: Intersect_(CN,AL); "H" at H +(4bp__,10bp__)
@@ -67,4 +67,28 @@ Fig2: [ ls = 3/4 # local scale
ArcAngle(R,Q,N,0.5); "$\alpha$" at last arc.start+(8bp__,-5bp__)
] with .w at Fig1.e+(-0.4,0)
+Fig3: [
+# https://tex.stackexchange.com/questions/609452/help-drawing-a-more-sophisticated-right-triangle-with-tikz-or-something-else
+gen_init
+
+define(`textsize',`\Large')
+ unit = 0.6
+ C: Here; { "textsize C" at C rjust below }
+ B: C+(4*unit,0); { "textsize B" at B ljust below }
+ A: C+(0,3*unit); { "textsize A" at A rjust above }
+ H: PerpTo(C,A,B); { "textsize H" at H ljust above }
+ line from C to H then to B then to C shaded rgbstring(0.5,0.8,0.9)
+# line from C to H then to B then to C shaded "CornflowerBlue"
+ line from C to H then to A then to C shaded rgbstring(0.8,0.9,0.7)
+# line from C to H then to A then to C shaded "SpringGreen"
+ ArcAngle(C,A,B,unit*0.4)
+ ArcAngle(C,A,B,unit*0.5)
+ ArcAngle(A,B,C,unit*0.5,,"textsize $\theta$" rjust)
+ ArcAngle(B,C,H,unit*0.5); {"textsize $\theta$" at C+(unit*0.3,unit*0.17) }
+ ArcAngle(B,C,A,unit*0.6)
+ RightAngle(B,C,A,unit*0.17)
+ RightAngle(C,H,A,unit*0.17)
+
+ ] with .nw at Fig1.sw+(0.2,-0.3)
+
.PE
diff --git a/graphics/circuit_macros/examples/Inductors.m4 b/graphics/circuit_macros/examples/Inductors.m4
index f250a81135..d9db4df153 100644
--- a/graphics/circuit_macros/examples/Inductors.m4
+++ b/graphics/circuit_macros/examples/Inductors.m4
@@ -30,8 +30,9 @@ vm = 0.4
{ebox(,,,0) ; move ;"`{ebox(,{,},0)}'" ljust}
move right_ hm -10bp__
{TI: tapped(`ebox(,,,0)',-,1/4,-dimen_/6,3/4,-dimen_/6) ; move ;
- "`tapped(\char96{}ebox(,{,},0)\char39,'" ljust at Here+(10bp__,-5bp__) \
- "-,1/4,-dimen\_/6," ljust "3/4,-dimen\_/6)" ljust
+ "`tapped(\char96{}ebox(,{,},0)\char39,'" ljust at Here+(10bp__,3bp__)
+ "`-,1/4,-dimen\_/6,'" ljust at last ""+(0,-11pt__)
+ "`3/4,-dimen\_/6)'" ljust at last ""+(0,-11pt__)
"\sl Tap1" at TI.Tap1 rjust below
"\sl Tap2" at TI.Tap2 ljust below }
}
diff --git a/graphics/circuit_macros/examples/IntersectingPlanes.m4 b/graphics/circuit_macros/examples/IntersectingPlanes.m4
new file mode 100644
index 0000000000..3ed9ab3bc3
--- /dev/null
+++ b/graphics/circuit_macros/examples/IntersectingPlanes.m4
@@ -0,0 +1,84 @@
+.PS
+## IntersectingPlanes.m4
+## Projection of an object defined by 4-sided facets
+threeD_init
+NeedDpicTools
+
+ setview( 10, 45)
+# Define the object by its facets:
+# size parameters
+ a = 3/2
+ b = 0.4
+# depth
+ d = -1
+# line ends and intersections
+ A0: -a,-b
+ A1: a,-b
+ B0: Rot_(A0,120)
+ B1: Rot_(A1,120)
+ C0: Rot_(A0,240)
+ C1: Rot_(A1,240)
+ AB: intersect_(A0,A1,B0,B1)
+ BC: intersect_(B0,B1,C0,C1)
+ CA: intersect_(C0,C1,A0,A1)
+
+ "A0" at project(0,A0.x,A0.y) rjust
+ "A1" at project(0,A1.x,A1.y) ljust
+ "B0" at project(0,B0.x,B0.y) ljust
+ "B1" at project(0,B1.x,B1.y) rjust
+ "C0" at project(0,C0.x,C0.y) ljust
+ "C1" at project(0,C1.x,C1.y) rjust
+# facet location parameters
+define(`facet',`$1.x,$1.y, $2.x,$2.y')
+array2(ffc,1,facet(A0,CA))
+array2(ffc,2,facet(CA,A0))
+array2(ffc,3,facet(CA,AB))
+array2(ffc,4,facet(AB,CA))
+array2(ffc,5,facet(AB,A1))
+array2(ffc,6,facet(A1,AB))
+
+array2(ffc,7,facet(AB,B0))
+array2(ffc,8,facet(B0,AB))
+array2(ffc,9,facet(BC,AB))
+array2(ffc,10,facet(AB,BC))
+array2(ffc,11,facet(B1,BC))
+array2(ffc,12,facet(BC,B1))
+
+array2(ffc,13,facet(C0,BC))
+array2(ffc,14,facet(BC,C0))
+array2(ffc,15,facet(BC,CA))
+array2(ffc,16,facet(CA,BC))
+array2(ffc,17,facet(CA,C1))
+array2(ffc,18,facet(C1,CA))
+nfacets = 18
+# facet corners
+define(`fSW',`0,ffc[($1,1)],ffc[($1,2)]')
+define(`fNW',`d,ffc[($1,1)],ffc[($1,2)]')
+define(`fSE',`0,ffc[($1,3)],ffc[($1,4)]')
+define(`fNE',`d,ffc[($1,3)],ffc[($1,4)]')
+# facet centre and normal
+define(`Fcentre',`sprod3D(0.5,sum3D(fSW(i),fNE(i)))')
+define(`Fnoarmal',`cross3D(diff3D(fSE($1),fSW($1)),diff3D(fNE($1),fSE($1)))')
+# facet drawing routine
+define(`drawfacet',`
+ Loopover_(`X', `X: project(m4xpand(f`'X)(`$1'));', SW,SE,NE,NW)
+ line from SW to SE then to NE then to NW then to SW shaded ifelse(`$3',,
+ "white", `rgbstring(`$3',ifelse(`$4',,`$3',`$4'),ifelse(`$5',,`$3',`$5'))')
+ ifelse(`$2',,,`sprintf("%g",$2) at 1/2 between NW and SE') ')
+
+# The rest is generic: sort visible facets by
+# distance and plot (but with custom colors)
+ nvis = 0
+ smax = 0
+ for i=1 to nfacets do {
+ if dot3D(View3D,Fnoarmal(i)) >= 0 then {
+ nvis +=1
+ s[nvis] = dot3D(View3D,Fcentre(i))
+ smax = max(smax,s[nvis])
+ ix[nvis] = i
+ } }
+ dpquicksort(s,1,nvis,ix)
+
+ for i=1 to nvis do { drawfacet(ix[i],ix[i],sqrt(i/nvis),i/nvis) }
+
+.PE
diff --git a/graphics/circuit_macros/examples/Makefile b/graphics/circuit_macros/examples/Makefile
index 4dc00e86f7..8e32490d6d 100644
--- a/graphics/circuit_macros/examples/Makefile
+++ b/graphics/circuit_macros/examples/Makefile
@@ -99,6 +99,10 @@ PDFLTXSRC=printf "|documentclass[11pt]{standalone}\n\
|pagestyle{empty}|thispagestyle{empty}\n\
|begin{document}|noindent|input{"$*".tex}|end{document}\n" | $(BS)
+# [dvipsnames]{xcolor} defines the colors near the end of:
+# https://steeven9.github.io/USI-LaTeX/html/packages_hyperref_babel_xcolor3.html
+# Better: use adjusted colors from http://latexcolor.com/
+
LTXFILE=printf "|documentclass[11pt]{article}\n\
|usepackage[dvipsnames]{xcolor}\n\
|usepackage{times,boxdims,graphicx,pstricks}\n\
@@ -255,7 +259,7 @@ clobber: clean
do (if test -d $$dir ; then cd $$dir; make clobber; fi) ; done
rm -f *.warn
rm -f examples.pdf
- rm -rf index.html html basenames *.png* dist zips htmlfiles
+ rm -rf index.html html basenames *.png* dist zips htmlfiles svgfiles
rm -rf $(TMP)/Cir* $(ECETMP)/Cir* $(ECEDIR)
if test -f Incl.pdf ; then \
mv Incl.pdf Incl.pdx; rm -f *.pdf; mv Incl.pdx Incl.pdf ; fi
diff --git a/graphics/circuit_macros/examples/Metamodel.m4 b/graphics/circuit_macros/examples/Metamodel.m4
new file mode 100644
index 0000000000..e5d1ba0b1c
--- /dev/null
+++ b/graphics/circuit_macros/examples/Metamodel.m4
@@ -0,0 +1,78 @@
+.PS
+# Metamodel:
+# https://tex.stackexchange.com/questions/615463/how-to-draw-meta-models-in-tikz
+gen_init
+
+ lineht = 0.4
+ arrowht = arrowht*3/2; arrowwid = arrowwid*2
+ fillv = 0.9
+ define bx {box fill_(fillv) rad 5bp__ $1}
+ up_
+
+ Event: bx(ht boxht "Event")
+ sarrow(,type=D); {"{\tt<}contains{\tt>}" at last arrow rjust}
+ Trace: bx(ht boxht "Trace")
+ sarrow(,type=D); {"{\tt<}contains{\tt>}" at last arrow rjust}
+ Log: bx(ht boxwid "Log")
+ Att: bx(ht boxwid wid boxwid*5/4 "Attribute" dashed) \
+ with .nw at Log.ne + (boxwid*2,0)
+
+ fillv = 0.8
+ ww = Log.ht
+ move to (Att.w,Att.n) - (0,ww/9)
+ { sarrow(to (Log.e,Here),type=D)
+ {"{\tt<}trace-global{\tt>}" at last arrow above} }
+ move down_ ww/3
+ { sarrow(to (Log.e,Here),type=D)
+ {"{\tt<}event-global{\tt>}" at last arrow above} }
+ move down_ ww/3
+ { sarrow(to (Log.e,Here),type=D) }
+ T: 0.8 between last arrow.start and last arrow.end
+ move down_ ww/9
+ line dashed left ww/3 then down ww/2 then right ww/2
+ sarrow(up ww*7/18, type=D;shaft=dashed)
+ "{\tt<}contains{\tt>}" at (last arrow.end,Att.s)-(ww/4,ww*7/18) below
+
+ line from T to (T,Event); sarrow(to Event.e,type=D)
+ sarrow(from (T,Trace) to Trace.e,type=D)
+
+ ellipsewid = boxwid*0.9
+ ellipseht = ellipsewid/2
+ move to (Att.e,Att.s)+(ww/6,-ww/8)
+ y = Here.x-Att.c.x-boxwid/2
+ down_
+ Loopover_(`Z',`Z: bx(ht boxht*3/4 "Z")
+ {sarrow(from Z.e+(y,0) to Z.e,type=D)}
+ {ifelse(Z,Boolean,
+ `move to last arrow.start; line to (Here,String)
+ line from Z.w to (Att,Z.w); sarrow(to Att.s,type=O)',
+ `line from Z.w to (Att,Z.w)')}
+ move down_ ww/16',
+ String,Date,Int,Float,Boolean)
+
+ line from Int.e+(y,0) right_ ww/4; Value: ellipse fill_(fillv) "Value"
+ Key: ellipse fill_(fillv) "Key" with .w at Att.e+(y*2,0)
+ sarrow(from last ellipse.w to Att.e,type=D)
+
+ Class: bx(ht boxht*3/4 "Classifier") \
+ with .s at (0.5 between Log and Att,Att.n)+(0,boxht/2)
+ line from Class.w to (Log,Class); sarrow(to Log.n,type=D)
+ "{\tt<}defines{\tt>}" at (0.5 between Log and Class.w,Class) above
+ line from Att.n to (Att,Class); sarrow(to Class.e,type=D)
+ "{\tt<}defines{\tt>}" at (0.5 between Att and Class.e,Class) above
+
+ Ext: bx(ht boxht*3/4 "Extension") with .e at (Att.e,Class+(0,boxht*3/2))
+ move to (Att.e,Att.n)-(Att.wid/8,0)
+ sarrow(to (Here,Ext.s),type=D;shaft=dashed)
+ "{\tt<}defines{\tt>}" at (last arrow,Ext.s)-(0,y) rjust
+ line dashed from Ext.w to (Log,Ext) then to (Log,Class)
+ "{\tt<}declares{\tt>}" at (0.5 between Log and Class,Ext) below
+
+ ellipse fill_(fillv) "name" at (Key,Ext)
+ sarrow(from last ellipse.w to Ext.e,type=D)
+ ellipse fill_(fillv) "prefix" with .n at last ellipse.s+(0,-ww/16)
+ line from last ellipse.w left y
+ URI: ellipse fill_(fillv) "URI" with .n at last ellipse.s+(0,-ww/16)
+ line from last ellipse.w left y then up Ext.y - URI.y
+
+.PE
diff --git a/graphics/circuit_macros/examples/MoreTable.m4 b/graphics/circuit_macros/examples/MoreTable.m4
index bfc41113c1..ef8cd71824 100644
--- a/graphics/circuit_macros/examples/MoreTable.m4
+++ b/graphics/circuit_macros/examples/MoreTable.m4
@@ -5,6 +5,11 @@ cct_init
movewid = 2 pt__
hm = 2.05
vm = 0.28
+{ right; {lamp ; move;"`{\tt lamp}'" ljust}
+ move right_ hm
+ {thermocouple ; move;"`{\tt thermocouple}'" ljust }
+}
+ move down 0.25; right_
{ {memristor ; move;"`{\tt memristor}'" ljust}
move right_ hm
{heater; move;"`{\tt heater}'" ljust}
@@ -26,11 +31,9 @@ vm = 0.28
{arrowline ; move;"`{\tt arrowline}'" ljust}
}
move down 0.25; right_
-{ move down 0.10; right; {lamp ; move;"`{\tt lamp}'" ljust}
+{ {xtal ; move ;"`{\tt xtal}'" ljust}
move right_ hm
- {thermocouple ; move;"`{\tt thermocouple}'" ljust }
-# move up 0.10 right_ hm
-# {arrester ; move ;"`{\tt arrester}'" ljust}
+ {xtal(,type=R;outerdiam=0.2) ; move ;"`{\tt xtal(,type=R)}'" ljust}
}
.PE
diff --git a/graphics/circuit_macros/examples/Resistors.m4 b/graphics/circuit_macros/examples/Resistors.m4
index 6e79c91966..659f75ff65 100644
--- a/graphics/circuit_macros/examples/Resistors.m4
+++ b/graphics/circuit_macros/examples/Resistors.m4
@@ -9,22 +9,32 @@ vm = 0.28
move right_ hm
{resistor(,,Q) ; move ;"`\tt resistor(,{,}Q) '" ljust}
move right_ hm
- {resistor(,,E) ; move
- "`\shortstack[l]{\tt resistor(,{,}E)\\ {\tt $\equiv$ ebox}}'" ljust}
+ {resistor(,,V) ; move ;"`{\tt resistor(,{,}V)}'" ljust}
}
move down vm; right_
{ {resistor(,,ES) ; move ;"`\tt resistor(,{,}ES) '" ljust}
move right_ hm
{resistor(,,H) ; move ;"`\tt resistor(,{,}H) '" ljust}
move right_ hm
- {ebox(,,,0.5) ; move ;"`{\tt ebox(,{,},0.5)}'" ljust}
+ {resistor(,,AC) ; move ;"`{\tt resistor(,{,}AC)}'" ljust}
}
move down vm; right_
-{ {resistor(,,V) ; move ;"`{\tt resistor(,{,}V)}'" ljust}
+{ {resistor(,,B) ; move ;"`{\tt resistor(,{,}B)}'" ljust}
+ move right_ hm
+ {resistor(,,E) ; move
+ "`\shortstack[l]{\tt resistor(,{,}E)\\ {\tt $\equiv$ ebox}}'" ljust}
move right_ hm
{ebox(,0.5,0.3) ; move ;"`{\tt ebox(,0.5,0.3)}'" ljust}
- move right_ hm+4bp__
- {resistor(,,B) ; move movewid-4bp__ ;"`{\tt resistor(,,B)}'" ljust}
+}
+ move down vm; right_
+{ {ebox(,,,0.9) ; move ;"`{\tt ebox(,{,},0.9)}'" ljust}
+ move right_ hm
+ {ebox(,,,,shaded "green") ; move
+ "`{\tt ebox(,{,},{,}shaded \"green\")}'" ljust}
+}
+ move down vm; right_
+{ {ebox(,wdth=0.2;box=dashed shaded "green";text="X") ; move
+ "`{\tt ebox(,wdth=0.2;box=dashed shaded \"green\";text=\"X\")}'" ljust}
}
.PE
diff --git a/graphics/circuit_macros/examples/Rotbox.m4 b/graphics/circuit_macros/examples/Rotbox.m4
index 7b33d769e8..4480b8d8bd 100644
--- a/graphics/circuit_macros/examples/Rotbox.m4
+++ b/graphics/circuit_macros/examples/Rotbox.m4
@@ -5,7 +5,8 @@ gen_init
Point_(-10)
rotbox(boxwid/2,,thick 2)
Point_(30)
- rotbox(,,shaded "green" outlined "blue",r=0.1) at last []+vec_(boxwid,0)
+ rotbox(,,shaded "yellow" outlined "blue" thick 3,r=0.1) \
+ at last []+vec_(boxwid,0)
"r=0.1" at last []
move to last [].ne
Point_(0)
diff --git a/graphics/circuit_macros/examples/Shaky.m4 b/graphics/circuit_macros/examples/Shaky.m4
index 7bd5113a57..7eff994d91 100644
--- a/graphics/circuit_macros/examples/Shaky.m4
+++ b/graphics/circuit_macros/examples/Shaky.m4
@@ -5,27 +5,27 @@ NeedDpicTools
divert(-1)
`An attempt to draw shaky hand-drawn lines'
- `shakyline(linespec,type,s=shake,[shakevals])
+ `shakyline(linespec,type,shake=expr,[shakevals])
Draw a line with a tremor
- arg3: s=shake parameter (default 1)
+ arg3: shake parameter (default 1)
arg4=normal(0,1) perturbations used if given'
define(`shakyline',
`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
- M4_start: last line.start
- M4_end: last line.end
- [ Start: M4_start
- End: M4_end
+ L_start_: last line.start
+ L_end_: last line.end
+ [ Start: L_start_
+ End: L_end_
llen = distance(Start,End)
npts = round_(llen/linewid*4)
- setkey_($3,s,1)
- if "$4"=="" then { randn(d,npts-1,0,m4s*(llen/npts/8)) }\
- else { for i=1 to npts-1 do { d[i] = $4[i]*m4s*(llen/npts/8) }}
+ setkey_($3,shake,1)
+ if "$4"=="" then { randn(d,npts-1,0,m4shake*(llen/npts/8)) }\
+ else { for i=1 to npts-1 do { d[i] = $4[i]*m4shake*(llen/npts/8) }}
P[0]: Start
for i=1 to npts-1 do { P[i]: i/npts between Start and End + (vec_(0,d[i])) }
P[npts]: End
spline $2 from P[0] to P[1]
for i=2 to npts do { continue to P[i] }
- ] with .Start at last line.start; move to last line.end')
+ ] with .Start at L_start_; move to L_end_')
`shakyarc(arcspec,type,s=shake,[shakevals])
Draw an arc with a tremor
@@ -33,12 +33,12 @@ define(`shakyline',
arg4=normal(0,1) perturbations used if given'
define(`shakyarc',
`arc invis $1
- M4_start: last arc.start
- M4_end: last arc.end
- M4_C: last arc.c
- [ Start: M4_start
- End: M4_end
- C: M4_C
+ A_start_: last arc.start
+ A_end_: last arc.end
+ A_C_: last arc.c
+ [ Start: A_start_
+ End: A_end_
+ C: A_C_
as = atan2(Start.y-C.y,Start.x-C.x)
ae = atan2(End.y-C.y,End.x-C.x)
ar = distance(Start,C)
@@ -60,10 +60,10 @@ define(`shakyarc',
arg4=normal(0,1) perturbations used if given'
define(`shakyspline',
`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
- M4_start: last line.start
- M4_end: last line.end
- [ Start: M4_start
- End: M4_end
+ SP_start_: last line.start
+ SP_end: last line.end
+ [ Start: SP_start_
+ End: SP_end
llen = distance(Start,End)
npts = round_(llen/linewid*4)
setkey_($3,s,1)
@@ -115,8 +115,9 @@ divert(0)
linethick = 2.5
round(,,colored "gray")
nl = 10
- for i=1 to nl do {
- shakyline(right 6/nl up 2*(2*pmod(i,2)-1),colored "gray",s=1)
+ for i=0 to nl do {
+ shakyline(right 6/nl up 2*(2*pmod(i,2)-1),colored "gray",shake=2-i/nl*2)
+ {sprintf("%g",2-i/nl*2) at 1/2 between L_start_ and L_end_ }
round(,,colored "gray") }
]
diff --git a/graphics/circuit_macros/examples/birds.m4 b/graphics/circuit_macros/examples/birds.m4
index 8d14ef1863..4b42ea35af 100644
--- a/graphics/circuit_macros/examples/birds.m4
+++ b/graphics/circuit_macros/examples/birds.m4
@@ -1,5 +1,7 @@
.PS
+# Birds.m4
gen_init
+
scale = 50
linethick = 2*linethick
diff --git a/graphics/circuit_macros/examples/control.m4 b/graphics/circuit_macros/examples/control.m4
index 400b8873ac..aa3de4bff9 100644
--- a/graphics/circuit_macros/examples/control.m4
+++ b/graphics/circuit_macros/examples/control.m4
@@ -15,15 +15,15 @@ S1: circle
line right "$e(s)$" above
{ arrow right ; box ht bh wid bw "$K_p$"
arrow right linewid-circlerad ; S2: circle }
- { line up linewid ; arrow right ; box ht bh wid bw "$K_D s$"
- line to (S2,Here) ; arrow to S2.n }
- { line down linewid ; arrow right ; box ht bh wid bw "$K_I/s$"
- line to (S2,Here) ; arrow to S2.s }
+ { arrow up linewid then right ; box ht bh wid bw "$K_D s$"
+ arrow to (S2,Here) then to S2.n }
+ { arrow down linewid then right ; box ht bh wid bw "$K_I/s$"
+ arrow to (S2,Here) then to S2.s }
arrow right from S2.e "$u(s)$" above
box "$G(s)$"
arrow right ; "$y(s)$" above rjust at Here+(0,2pt__)
- line down boxht*3/2 from last arrow.c then left last arrow.c.x-S1.x
- arrow to S1.s
+ arrow down boxht*3/2 from last arrow.c then left last arrow.c.x-S1.x \
+ then to S1.s
"$-\;$" below rjust
]
"(a) $PID$ control" below ljust at PID.sw+(0,-5pt__)
@@ -190,7 +190,7 @@ E: circle
box "stabilizer" "$K$"
arrow "$\delta u$" above
D: circle
- line from Gh.e to (D,Gh.e) "$u_{\hbox{\scriptsize ref}}$" above
+ line from Gh.e to (D,Gh.e) "$u_{\hbox{\scriptsize ref}}$" above; corner
arrow to D.n
arrow from D.e right "$u$" above
G: box "plant" "$G$"
diff --git a/graphics/circuit_macros/examples/ex01.m4 b/graphics/circuit_macros/examples/ex01.m4
index e672fccc36..a566c4c2dd 100644
--- a/graphics/circuit_macros/examples/ex01.m4
+++ b/graphics/circuit_macros/examples/ex01.m4
@@ -17,13 +17,13 @@ Timer: [
define(`elen_',`linewid')
Vs: dot
down_
- variable(`resistor(,E); llabel(,\SI{1}{M})')
- resistor(,E); llabel(,\SI{100}{\kilo{}})
+ variable(`resistor(,,E); llabel(,\SI{1}{M})')
+ resistor(,,E); llabel(,\SI{100}{\kilo{}})
capacitor(,E); llabel(\SI{220}{\micro{}})
Zero: dot
dot(at Vs+(elen_*4/3,0))
- resistor(,E); llabel(,\SI{33}{\kilo{}})
+ resistor(,,E); llabel(,\SI{33}{\kilo{}})
line to (Here,Zero) chop 0 chop elen_
C2: capacitor; llabel(\SI{0.1}{\micro{}})
dot
@@ -41,7 +41,7 @@ R: dot
B: buzzer(,,C) with .In3 at Here
line from B.In1 to (R,B.In1)
reversed(`diode',to (Here,Vs),LE); "red" at last line.c+(elen_/2,0)
- resistor(down_ elen_ from R,E); llabel(,\num{470})
+ resistor(down_ elen_ from R,,E); llabel(,\num{470})
diode(to (Here,Zero),LE); {"green" at last line.c+(elen_*2/3,0)}
line to Zero chop 0 chop -elen_
line up_ (Vs.y-Here.y)/3
diff --git a/graphics/circuit_macros/examples/examples.pdf b/graphics/circuit_macros/examples/examples.pdf
index 300ab4abed..6d02c456cc 100644
--- a/graphics/circuit_macros/examples/examples.pdf
+++ b/graphics/circuit_macros/examples/examples.pdf
Binary files differ
diff --git a/graphics/circuit_macros/examples/examples.tex b/graphics/circuit_macros/examples/examples.tex
index 2b252a4e18..79979379bb 100644
--- a/graphics/circuit_macros/examples/examples.tex
+++ b/graphics/circuit_macros/examples/examples.tex
@@ -6,7 +6,7 @@
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{boxdims}
-\usepackage{upgreek}
+%\usepackage{upgreek}
\usepackage{siunitx}
\usepackage{amssymb}
@@ -35,7 +35,7 @@
This document duplicates a few diagrams from the manual
Circuit\_macros.pdf. There are also a few files in the
examples directory that are not included in this document. To process
- {\sl file}.m4, for example, type "make {\sl file}.pdf."
+ {\sl file}.m4, for example, type "make {\sl file}.pdf".
\input files
\endinput
@@ -54,9 +54,11 @@ debug2.m4
Escher.m4
Euro.m4
Floor.m4
+Geometry.m4
IC10107.m4
keyval.m4
Koch.m4
+Metamodel.m4
OpAmpFilter.m4
Orbits.m4
person.m4
diff --git a/graphics/circuit_macros/examples/files.tex b/graphics/circuit_macros/examples/files.tex
index a33d0dc50d..5a04b20edc 100644
--- a/graphics/circuit_macros/examples/files.tex
+++ b/graphics/circuit_macros/examples/files.tex
@@ -8,7 +8,7 @@
\bfig{
\centerline{{\small\getpic{Resistors}}}
- \caption{Resistors, showing some variations
+ \caption{Resistors, showing some variations and the ebox
\src{Resistors.m4}.}
}
@@ -37,15 +37,15 @@
}
\bfig{
- \centerline{\getpic{Sources}}
- \caption{Sources and source-like elements
- \src{Sources.m4}.}
+ \centerline{\getpic{Variable}}
+ \caption{Arrows and marks for showing variability
+ \src{Variable.m4}.}
}
\bfig{
- \centerline{\getpic{Variable}}
- \caption{Arrows and marks indicating variability
- \src{Variable.m4}.}
+ \centerline{\getpic{Sources}}
+ \caption{Sources and source-like elements
+ \src{Sources.m4}.}
}
\bfig{
@@ -85,18 +85,18 @@
}
\bfig{
- \centerline{\getpic{Audio}}
- \caption{Audio elements
- \src{Audio.m4}.}
- }
-
-\bfig{
{\small\centerline{\getpic{Opamp}} }
\caption{The opamp
\src{Opamp.m4}.}
}
\bfig{
+ \centerline{\getpic{Audio}}
+ \caption{Audio elements
+ \src{Audio.m4}.}
+ }
+
+\bfig{
{\small\centerline{\getpic{Xform}} }
\caption{The transformer element, drawing direction down
\src{Xform.m4}.}
@@ -273,12 +273,6 @@
}
\bfig{
- \centerline{\getpic{MC}}
- \caption{A three-phase switched AC-AC converter and a DC-DC converter
- \src{MC.m4}.}
- }
-
-\bfig{
\centerline{\getpic{ex10}}
\caption{Non-planar graph and bistable circuit
(illustrating the {\tt crossover} macro and colored elements)
@@ -292,6 +286,12 @@
}
\bfig{
+ \centerline{\getpic{MC}}
+ \caption{A three-phase switched AC-AC converter and a DC-DC converter
+ \src{MC.m4}.}
+ }
+
+\bfig{
\centerline{\getpic{ex17}}
\caption{A repetitive network created by Pic looping and
a skewed circuit used to test the macro {\tt parallel\_}
@@ -478,7 +478,7 @@
The function tree is drawn, then a row or column of inputs, then
the connections. The default result is on the left,
a custom element at the top, and a tree of gates only is shown
- on the right. THe lower examples illustrate the L, R, and V options.)
+ on the right.
\src{Alogix.m4}.}
}
@@ -562,18 +562,18 @@
}
\bfig{
- \centerline{\getpic{Plate}}
- \caption{Dimensioning with tolerances
- \src{Plate.m4}.}
- }
-
-\bfig{
\centerline{\getpic{ex05}}
\caption{Use of {\tt darrow}
\src{ex05.m4}.}
}
\bfig{
+ \centerline{\getpic{Plate}}
+ \caption{Dimensioning with tolerances
+ \src{Plate.m4}.}
+ }
+
+\bfig{
\centerline{\getpic{Loglog}}
\caption{A graph drawn using the pic language
\src{Loglog.m4}.}
@@ -599,7 +599,6 @@
determines plotting order
\src{graysurf.m4}.}
}
-\clearpage
\bfig{
\centerline{\getpic{shapes}}
@@ -680,7 +679,7 @@
\bfig{
\centerline{\getpic{Counting}}
\caption{An example of enumeration
- \src{Counting.m4}.}
+ src{Counting.m4}.}
}
\bfig{
diff --git a/graphics/circuit_macros/examples/mf/cct.mf b/graphics/circuit_macros/examples/mf/cct.mf
index dd0dcdfd11..16e77f4cbd 100644
--- a/graphics/circuit_macros/examples/mf/cct.mf
+++ b/graphics/circuit_macros/examples/mf/cct.mf
@@ -1,5 +1,5 @@
% cct.mf, generated by Mfpic, v1.10 2012/12/03,
-% from TeX source "font" on 2021/06/02 at 22:43
+% from TeX source "font" on 2021/10/02 at 01:36
numeric mfpicversion; mfpicversion := 110;
if unknown mode: mode := localfont; fi
if unknown mag: mag := 1000/1000; fi
diff --git a/graphics/circuit_macros/examples/squiggle.m4 b/graphics/circuit_macros/examples/squiggle.m4
index af5831f593..671ae2addd 100644
--- a/graphics/circuit_macros/examples/squiggle.m4
+++ b/graphics/circuit_macros/examples/squiggle.m4
@@ -1,4 +1,5 @@
.PS
+# squiggle.m4
gen_init
divert(-1)
@@ -20,6 +21,6 @@ divert(0)dnl
squiggle(up_ 1 right_ 2,,,outlined "red")
squiggle(up 2 right_ 2,0.1,0.15,outlined "red" <-> wid 0.06 ht 0.05)
-squiggle(right_ 1,,,dotted outlined "blue" wid 0.06 ht 0.05)
+squiggle(right_ 1,,,thick 2 dotted outlined "blue" )
.PE
diff --git a/graphics/circuit_macros/examples/svg/ByteSVG.m4 b/graphics/circuit_macros/examples/svg/ByteSVG.m4
index fcd6bdce60..ca059487e7 100644
--- a/graphics/circuit_macros/examples/svg/ByteSVG.m4
+++ b/graphics/circuit_macros/examples/svg/ByteSVG.m4
@@ -1,5 +1,5 @@
-% Byte.m4
.PS
+# Byte.m4
gen_init(svg_font(sans-serif,11bp__))
boxht = 0.2
boxwid = 3.5
diff --git a/graphics/circuit_macros/examples/svg/CapacitorsSVG.m4 b/graphics/circuit_macros/examples/svg/CapacitorsSVG.m4
index 1942860d37..be6a8edd47 100644
--- a/graphics/circuit_macros/examples/svg/CapacitorsSVG.m4
+++ b/graphics/circuit_macros/examples/svg/CapacitorsSVG.m4
@@ -1,5 +1,5 @@
.PS
-# `Capacitors.m4'
+# `CapacitorsSVG.m4'
cct_init(svg_font(sans-serif,11pt__))
textwid = 1.5
movewid = 2 pt__
@@ -26,12 +26,17 @@ vm = 0.28
move right_ hm
{capacitor(,N); move ; "`capacitor(,N) '" ljust}
move right_ hm
- {xtal ; move ; "`xtal '" ljust}
+ {capacitor(,CP); move ; "`capacitor(,CP) '" ljust}
+# {xtal ; move ; "`xtal '" ljust}
}
move down 0.25; right_
{ {capacitor(,dC); move ;"`capacitor(,dC) '" ljust}
move right_ hm
{capacitor(,dF); move ;"`capacitor(,dF) '" ljust}
+ move right_ hm
+ {variable(`capacitor',NN,-30,dimen_/3)
+ move ;"`variable('svg_grave`capacitor'svg_prime`,'" wid 97bp__ ljust \
+ "` NN,-30,dimen_/3)'" ljust }
}
command "</g>" # end font
diff --git a/graphics/circuit_macros/examples/svg/ChipsSVG.m4 b/graphics/circuit_macros/examples/svg/ChipsSVG.m4
index 3d9ccb1edc..b85ce8d970 100644
--- a/graphics/circuit_macros/examples/svg/ChipsSVG.m4
+++ b/graphics/circuit_macros/examples/svg/ChipsSVG.m4
@@ -30,7 +30,7 @@ DIPs: [
{ arrow <- from DIP0.Pin8 up 0.25 right 0.2 ; "svg_it(`Pin8')" above ljust }
{ "svg_tt(`DIP(32,direct=R;bodywid=0.5*scale)')" ljust \
- at DIP32.sw - (0,10bp__) }
+ at DIP32.sw - (20bp__,10bp__) }
{ arrow <- right 0.2 from DIP32.Pin1; "svg_it(`Pin1')" ljust }
{ spline <- right 0.2 then right 0.1 up 0.1 from DIP32.Pin32
"svg_it(`Pin32')" ljust }
diff --git a/graphics/circuit_macros/examples/svg/EEPSVG.m4 b/graphics/circuit_macros/examples/svg/EEPSVG.m4
index 4f928f927d..277b704cd8 100644
--- a/graphics/circuit_macros/examples/svg/EEPSVG.m4
+++ b/graphics/circuit_macros/examples/svg/EEPSVG.m4
@@ -10,36 +10,38 @@ divert(-1)
# already in libcct.m4. The contributions and suggestions of Benjamin
# Vilmann are acknowledged with thanks.
-# 1-terminal SLD elements:
+# Notes for 1-terminal SLD elements:
# Argument 1 is normally the linespec of the stem to set the element direction
-# and length. See also: PtoL defined below.
+# and length. See also: PtoL defined in libgen.m4.
# For a 0-length stem (which has undefined direction):
# arg1 can also be U, D, L, R (for up, down, left, right),
# or a number to set the direction in degrees, optionally followed by
# `at position' to set the position (Here by default).
# Zero-length stem examples: sl_box(U), sl_box(45 at Here+(1,0))
# Argument 2 contains semicolon (;)-separated key-value attributes
-# of the element head as applicable: e.g., name=Name; text="text"; lgth=expr
-# A non-blank argument 3 is C for a default closed breaker in the stem, O for
-# an open breaker, or key-value pairs to specify breaker details.
-# The element body (head) can be named. It is overlaid with or contained in
-# a [] block.
-
-# 2-terminal SLD elements:
+# of the element head as applicable: e.g., name=Carol; text="Stop"; lgth=expr
+# If argument 3 is blank then no breaker is drawn. A non-blank argument 3
+# is C for a default closed breaker in the stem, O for an open breaker,
+# or key-value pairs to specify breaker details.
+# The element body (head) can be named with name=. It is overlaid with
+# or contained in a [] block.
+
+# Notes for 2-terminal SLD elements:
# These obey the normal Circuit_macro two-terminal conventions.
# They can be labelled using rlabel() or llabel() as well as directly.
# Argument 2 contains key-value pairs to customize the element body,
# e.g., name=Name; text="text"; wdth=expr; ...
# Nonblank arguments 3 and 4 put a breaker in the input and output respectively.
-# Attached breakers:
+# Notes for attached breakers:
# Nonblank arguments 3 and 4 of the two-terminal elements and argument 3 of
# the 1-terminal elements specify a breaker in the input, output, and stem
# respectivlely. An O creates a default-size open breaker, and C a closed
# breaker, otherwise the argument contains key-value pairs to specify the
# details of the box; e.g., box=dotted 2bp__ shaded "green"
-# The SLD current transformer macro sl_ct is composite, within a [] block.
+# Notes for composite elements within a [ ] block:
+# The SLD current transformer macro sl_ct is composite.
# Internal labels L (for inductor) and terminals Ts, Tc, and Te are defined.
define(`sldlib_')
@@ -195,24 +197,31 @@ define(`sl_eleminit_',
input breaker keys, output breaker keys)
keys:
type=I|S
- (type=I) scale=expr; (default 1.5)
+ (type=I) loopwid=expr; (default dimen_*3/10)
cycles=n; (default 4)
+ core= A[ir]|M[n]|P[n]|K[n]
+ n=integer (default 2 lines)
(type=S) body=shaded "color";
name=Body name;
(breaker default names BrI, BrO)'
define(`sl_transformer',
- `setkeys_(`$2',name::N; type:I:N; cycles:4:N; body::N; scale:1.5:; )dnl
+ `setkeys_(`$2',name::N; type:I:N; cycles:4:N; core::N; body::N;
+ loopwid:3/20*dimen_; )dnl
ifelse(`$3'`$4',,
`ifinstr(m4type,S,
`source(`$1',G,,,m4body)',
`eleminit_(`$1'); m4atmp = rp_ang; m4slen = rp_len
- define(`m4swd',`dimen_*3/16*m4scale')dnl
+ ifelse(ifinstr(m4core,M,T,m4core,P,T,m4core,K,T),T,
+ `define(`m4nL',ifelse(len(m4core),1,2,substr(m4core,1)))dnl
+ define(`m4swd',(m4loopwid + dimen_/12+(m4nL-1)*dimen_/16))',dnl
+ `define(`m4swd',(m4loopwid*3/2))')dnl
{ line to rvec_((m4slen-m4swd)/2,0)
- {ifelse(m4name,,SL_box,m4name): [ linewid = linewid*m4scale
- {L1: inductor(to vec_(0,-m4cycles*dimen_/8),,m4cycles)}
+ {ifelse(m4name,,SL_box,m4name): [#linewid = linewid*m4scale
+ {L1: inductor(to vec_(0,-m4cycles*m4loopwid),,m4cycles,m4core,
+ m4loopwid)}
{point_(m4atmp)
- L2: inductor(from vec_(dimen_*3/16,-m4cycles*dimen_/8) \
- to vec_(dimen_*3/16,0),,m4cycles)}
+ L2: inductor(from vec_(m4swd,-m4cycles*m4loopwid) \
+ to vec_(m4swd,0),,m4cycles,,m4loopwid)}
C2: last line.c; point_(m4atmp) ] with .L1.c at Here}
line from rvec_(m4swd,0) to rvec_((m4slen+m4swd)/2,0) }
line invis to rvec_(rp_len,0)') ',
@@ -389,6 +398,17 @@ define(`sl_ct',
# #######################################################################
+# The following is defined in Circuit_macros 9.5.4 or later:
+
+ `setkeys_(string,keysequence)
+ Invoke setkey_ on arg1 and each term in a
+ sequence of terms.
+ keysequence is a ;-separated sequence
+ of terms of the form
+ identifier:default value:N '
+define(`setkeys_',`Loopover_(`M4sk',`setkey_(`$1',patsubst(M4sk,:,`,')) dnl',
+ patsubst(`$2',;,`,'))')
+
divert(0)dnl
diff --git a/graphics/circuit_macros/examples/svg/GeometrySVG.m4 b/graphics/circuit_macros/examples/svg/GeometrySVG.m4
index bb6ff0bd2a..5dc1284d08 100644
--- a/graphics/circuit_macros/examples/svg/GeometrySVG.m4
+++ b/graphics/circuit_macros/examples/svg/GeometrySVG.m4
@@ -1,9 +1,10 @@
.PS
# Geometry.m4
gen_init
+ maxpswid = 10
scale = 5/4
-G: [
+Fig1: [
A: Here; "A" at A above
B: A+(-1,-3.5); "B" at B below rjust
@@ -12,7 +13,7 @@ G: [
BC: line from B to C
CA: line from C to A
- PerpTo(A,BC,L); "L" at L below
+ perpto(A,BC,L); "L" at L below
AL: line from A to L; RightAngle(A,L,C)
angleLAC = atan2(C.x-L.x,A.y-L.y)
@@ -20,10 +21,10 @@ G: [
AW: line from A to Intersect_(S,BC)
W: Here; "W" at W below rjust
- PerpTo(C,AB,N); "N" at N above rjust
+ perpto(C,AB,N); "N" at N above rjust
CN: line from C to N; RightAngle(C,N,B)
- PerpTo(B,CA,M); "M" at M above
+ perpto(B,CA,M); "M" at M above
CM: line from B to M; RightAngle(B,M,C)
H: Intersect_(CN,AL); "H" at H +(4bp__,10bp__)
@@ -45,7 +46,8 @@ G: [
line dashed from X to Y chop -linewid/2
RightAngle(A,Z,Y)
] scaled 0.8
-Lyap: [
+
+Fig2: [
#.PS
# Lyap.m4
threeD_init
@@ -205,6 +207,27 @@ arrow from F[n/2] to Project(0,0,2)
"svg_it(v(X) = c)" at (Project(vp(100*dtor_,c)))+(2bp__,0) above ljust
#.PE
- ] scaled 1.5 with .sw at last [].se+(0.5,0)
+ ] scaled 1.5 with .w at last [].e+(0.5,0)
+
+Fig3: [
+# https://tex.stackexchange.com/questions/609452/help-drawing-a-more-sophisticated-right-triangle-with-tikz-or-something-else
+gen_init
+
+ unit = 0.8
+ C: Here; { "C" at C rjust below }
+ B: C+(4*unit,0); { "B" at B ljust below }
+ A: C+(0,3*unit); { "A" at A rjust above }
+ H: PerpTo(C,A,B); { "H" at H ljust above }
+ line from C to H then to B then to C shaded rgbstring(0.5,0.8,0.9)
+ line from C to H then to A then to C shaded rgbstring(0.8,0.9,0.7)
+ ArcAngle(C,A,B,unit*0.4)
+ ArcAngle(C,A,B,unit*0.5)
+ ArcAngle(A,B,C,unit*0.5,,"svg_theta" rjust)
+ ArcAngle(B,C,H,unit*0.5); {"svg_theta" at C+(unit*0.3,unit*0.17) }
+ ArcAngle(B,C,A,unit*0.6)
+ RightAngle(B,C,A,unit*0.17)
+ RightAngle(C,H,A,unit*0.17)
+
+ ] with .sw at Fig2.se+(0.2,0)
.PE
diff --git a/graphics/circuit_macros/examples/svg/MoreTableSVG.m4 b/graphics/circuit_macros/examples/svg/MoreTableSVG.m4
index e06efb5d5e..5966216c59 100644
--- a/graphics/circuit_macros/examples/svg/MoreTableSVG.m4
+++ b/graphics/circuit_macros/examples/svg/MoreTableSVG.m4
@@ -35,6 +35,8 @@ vm = 0.28
{thermocouple ; move;"`thermocouple '" ljust }
# move up 0.10 right_ hm
# {arrester ; move ;"`arrester '" ljust}
+ move right_ hm
+ {xtal ; move ;"`xtal '" ljust}
}
command "</g>" # end font
diff --git a/graphics/circuit_macros/examples/svg/ResistorsSVG.m4 b/graphics/circuit_macros/examples/svg/ResistorsSVG.m4
index 4fb0be47f0..4da2b4f344 100644
--- a/graphics/circuit_macros/examples/svg/ResistorsSVG.m4
+++ b/graphics/circuit_macros/examples/svg/ResistorsSVG.m4
@@ -8,26 +8,40 @@ vm = 0.28
hm = 2.05
vm = 0.28
-{ {resistor ; move ; svgLink(NportSVG.svg,"`resistor'" ljust)}
+{
+ {resistor ; move ; svgLink(NportSVG.svg,"`resistor'" ljust)}
move right_ hm
{resistor(,,Q) ; move ; "`resistor(,,Q) '" ljust}
move right_ hm
- {resistor(,,E) ; move
- "`resistor(,,E)'" ljust " svg_equiv `ebox'" ljust}
+ {resistor(,,V) ; move ; "`resistor(,,V) '" ljust}
}
move down vm; right_
-{ {resistor(,,ES) ; move ; "`resistor(,,ES) '" ljust}
+{
+ {resistor(,,ES) ; move ; "`resistor(,,ES) '" ljust}
move right_ hm
{resistor(,,H) ; move ; "`resistor(,,H) '" ljust}
move right_ hm
- {ebox(,,,0.5) ; move ; "`ebox(,,,0.5) '" ljust}
+ {resistor(,,AC) ; move ; "`resistor(,,AC) '" ljust}
}
move down vm; right_
-{ {resistor(,,V) ; move ; "`resistor(,,V) '" ljust}
+{
+ {resistor(,,B) ; move ; "`resistor(,,B) '" ljust}
+ move right_ hm
+ {resistor(,,E) ; move
+ "`resistor(,,E)'" ljust " svg_equiv `ebox'" ljust}
move right_ hm
{ebox(,0.5,0.3) ; move ;"`ebox(,0.5,0.3) '" ljust}
- move right_ hm+4bp__
- {resistor(,,B) ; move movewid-4bp__ ; "`resistor(,,B) '" ljust}
+}
+ move down vm; right_
+{
+ {ebox(,,,0.6) ; move ; "`ebox(,,,0.6) '" ljust}
+ move right_ hm
+ {ebox(,,,,shaded "green") ; move ;"`ebox(,,,,shaded \"green\") '" ljust}
+}
+ move down vm; right_
+{
+ {ebox(,wdth=0.2;box=dashed shaded "green";text="X") ; move
+ "`ebox(,wdth=0.2;box=dashed shaded \"green\";text=\"X\")'" ljust}
}
command "</g>" # end font
diff --git a/graphics/circuit_macros/examples/svg/RotboxSVG.m4 b/graphics/circuit_macros/examples/svg/RotboxSVG.m4
index 3d4fbde82b..cb65d317fc 100644
--- a/graphics/circuit_macros/examples/svg/RotboxSVG.m4
+++ b/graphics/circuit_macros/examples/svg/RotboxSVG.m4
@@ -1,5 +1,5 @@
-% Rotbox.m4
.PS
+# RotboxSVG.m4
gen_init
#nclude(dpictools.pic)
@@ -7,7 +7,8 @@ gen_init
Point_(-10)
rotbox(boxwid/2,,thick 2)
Point_(30)
- rotbox(,,shaded "green" outlined "blue",r=0.1) at last []+vec_(boxwid,0)
+ rotbox(,,shaded "yellow" outlined "blue" thick 3,r=0.1) \
+ at last []+vec_(boxwid,0)
"r=0.1" at last []
move to last [].ne
Point_(0)
diff --git a/graphics/circuit_macros/examples/svg/SLD.m4 b/graphics/circuit_macros/examples/svg/SLD.m4
new file mode 100644
index 0000000000..96f04f7235
--- /dev/null
+++ b/graphics/circuit_macros/examples/svg/SLD.m4
@@ -0,0 +1,389 @@
+divert(-1)
+
+# This section defines *DRAFT* SLD elements with or without attached
+# circuit breakers. Many other elements applicable to SLD drawings are
+# already in libcct.m4. The contributions and suggestions of Benjamin
+# Vilmann are acknowledged with thanks.
+
+# Notes for 1-terminal SLD elements:
+# Argument 1 is normally the linespec of the stem to set the element direction
+# and length. See also: PtoL defined in libgen.m4.
+# For a 0-length stem (which has undefined direction):
+# arg1 can also be U, D, L, R (for up, down, left, right),
+# or a number to set the direction in degrees, optionally followed by
+# `at position' to set the position (Here by default).
+# Zero-length stem examples: sl_box(U), sl_box(45 at Here+(1,0))
+# Argument 2 contains semicolon (;)-separated key-value attributes
+# of the element head as applicable: e.g., name=Carol; text="Stop"; lgth=expr
+# If argument 3 is blank then no breaker is drawn. A non-blank argument 3
+# is C for a default closed breaker in the stem, O for an open breaker,
+# or key-value pairs to specify breaker details.
+# The element body (head) can be named with name=. It is overlaid with
+# or contained in a [] block.
+
+# Notes for 2-terminal SLD elements:
+# These obey the normal Circuit_macro two-terminal conventions.
+# They can be labelled using rlabel() or llabel() as well as directly.
+# Argument 2 contains key-value pairs to customize the element body,
+# e.g., name=Name; text="text"; wdth=expr; ...
+# Nonblank arguments 3 and 4 put a breaker in the input and output respectively.
+
+# Notes for attached breakers:
+# Nonblank arguments 3 and 4 of the two-terminal elements and argument 3 of
+# the 1-terminal elements specify a breaker in the input, output, and stem
+# respectivlely. An O creates a default-size open breaker, and C a closed
+# breaker, otherwise the argument contains key-value pairs to specify the
+# details of the box; e.g., box=dotted 2bp__ shaded "green"
+
+# Notes for composite elements within a [ ] block:
+# The SLD current transformer macro sl_ct is composite.
+# Internal labels L (for inductor) and terminals Ts, Tc, and Te are defined.
+
+define(`sldlib_')
+ifdef(`libcct_',,`include(libcct.m4)divert(-1)')
+
+# Default size parameters. These can be redefined in a diagram.
+
+define(`brksiz_',`dimen_*3/16') # Default inline box breaker size
+define(`drosiz_',`dimen_/4') # Default sl_drawout (chevron) size
+
+# One-terminal elements ###################################################
+
+ `sl_disk( stem linespec, keys, breaker )
+ keys: name=Name;
+ text="text";
+ diam=expr;
+ circle=circle attributes; eg diam expr'
+ `default breaker name Bd'
+define(`sl_disk',
+ `sl_eleminit_(`$1')
+ setkeys_(`$2',`name::N; circle::N; text::N; diam:dimen_*2/3')dnl
+ ifelse(`$3',,
+ `ifelse(m4name,,,m4name:) circle diam m4diam \
+ at last line.end + vec_(m4diam/2,0) m4circle m4text
+ [ box invis wid_ m4diam ht_ m4diam ] at last circle
+ line from last line.end to last line.start',
+ `m4br_one(`sl_disk',`$1',`$2',m4brk_(`$3',Bd))') ')
+
+ `sl_box( stem linespec, keys, breaker )
+ keys: name=Name; lgth=expr; wdth=expr;
+ text="text";
+ box= box attributes; (e.g. shade "red")'
+ `default breaker name Bb'
+define(`sl_box',
+ `sl_eleminit_(`$1')
+ setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl
+ ifelse(`$3',,
+ `line from last line.end to last line.start
+ { ifelse(m4name,,,m4name:) [S:Here; lbox(m4lgth,m4wdth,m4box)] \
+ with .S at last line.start }
+ ifelse(m4text,,,`{m4text at last []}')',
+ `m4br_one(`sl_box',`$1',`$2',m4brk_(`$3',Bb))') ')
+
+ `sl_grid( stem linespec, keys, breaker )
+ keys: name=Name; lgth=expr; wdth=expr;'
+ `default breaker name Bgr'
+define(`sl_grid',
+ `sl_eleminit_(`$1')
+ setkeys_(`$2',`name::N; wdth:dimen_*4/5; lgth:dimen_*2/3; box::N; text::N')dnl
+ ifelse(`$3',,
+ `line from last line.end to last line.start
+ { ifelse(m4name,,,m4name:) [S:Here
+ { ifelse(m4name,,,m4name:) lbox(m4lgth,m4wdth) }
+ { line to rvec_(m4lgth/2, m4wdth/2)
+ line to rvec_(m4lgth/2,-m4wdth/2)
+ line to rvec_(-m4lgth/2,-m4wdth/2)
+ line to rvec_(-m4wdth/2, m4wdth/2) }
+ { line from rvec_(0,m4wdth/2) to rvec_(m4lgth,-m4wdth/2) }
+ line from rvec_(0,-m4wdth/2) to rvec_(m4lgth,m4wdth/2)
+ ] with .S at last line.start } ',
+ `m4br_one(`sl_grid',`$1',`$2',m4brk_(`$3',Bgr))') ')
+
+ `sl_load( stem linespec, keys, breaker )
+ keys: name=Name; lgth=expr; wdth=expr;
+ head= arrowhead attributes;'
+ `default breaker name Bl'
+define(`sl_load',
+ `sl_eleminit_(`$1')
+ setkeys_(`$2',`name::N; wdth:dimen_*0.32; lgth:dimen_*0.45; head::N')dnl
+ ifelse(`$3',,
+ `line from last line.end to last line.start
+ { ifelse(m4name,,,m4name:) [S:Here; line to rvec_(0,m4wdth/2) \
+ then to rvec_(m4lgth,0) then to rvec_(0,-m4wdth/2) \
+ then to Here m4head ] with .S at last line.start } ',
+ `m4br_one(`sl_load',`$1',`$2',m4brk_(`$3',Bl))') ')
+
+ `sl_meterbox( stem linespec, keys, breaker )
+ keys: sl_box attributes'
+ `default breaker name Bm'
+define(`sl_meterbox',
+ `sl_eleminit_(`$1')
+ setkeys_(`$2',`name::N; wdth:dimen_*2/3; lgth:dimen_*2/3; box::N; text::N')dnl
+ ifelse(`$3',,
+ `line from last line.end to last line.start
+ {ifelse(m4name,,,m4name:) [S:Here;
+ { B: rotbox( m4lgth, m4wdth, m4box ) with .W at S }
+ a = rp_ang*rtod_
+ if (abs(a-90) < 45) || (abs(a-180) < 45) || (abs(a+180) < 45) then {
+ C: rvec_(m4lgth*2/5,0)
+ line from rvec_(m4lgth*4/5,m4wdth/2) to rvec_(m4lgth*4/5,-m4wdth/2) } \
+ else { C: rvec_(m4lgth*3/5,0)
+ line from rvec_(m4lgth/5,m4wdth/2) to rvec_(m4lgth/5,-m4wdth/2) }
+ ifelse(m4text,,,`m4text at C')
+ ] with .S at last line.start}',
+ `m4br_one(`sl_meterbox',`$1',`$2',m4brk_(`$3',Bm))') ')
+
+ `sl_generator( stem linespec, keys, breaker )'
+ `default breaker name Bd'
+define(`sl_generator',`sl_disk($@)
+ { ACsymbol(at last circle,,,R)
+ m4lcd = last circle.diam
+ [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ')
+
+ `sl_syncmeter( stem linespec, keys, breaker )'
+ `default breaker name Bd'
+define(`sl_syncmeter',`sl_disk($@)
+ { Syncsymb(at last circle)
+ m4lcd = last circle.diam
+ [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ')
+
+ `sl_lamp( stem linespec, keys, breaker )'
+ `default breaker name Bd'
+define(`sl_lamp',`sl_disk($@)
+ { line from last circle.ne to last circle.sw
+ line from last circle.nw to last circle.se
+ m4lcd = last circle.diam
+ [ box invis wid_ m4lcd ht_ m4lcd ] at last circle } ')
+
+# One-terminal utilities ##################################################
+
+ `Syncsymb(at position, rad)
+ Symbol for sync meter'
+define(`Syncsymb',`[ define(`m4ssrad',`ifelse(`$2',,(dimen_/4),`($2)')')dnl
+ Origin: Here
+ {arc <-> ht arrowht/2 wid arrowwid*2/3 \
+ from Rect_(m4ssrad,30) to Rect_(m4ssrad,150) with .c at Here}
+ line from (0,m4ssrad) to (0,-m4ssrad/2)
+ `$3' ] with .Origin ifelse(`$1',,`at Here',`$1')')
+
+ `m4br_one( `name', stem linespec, body keys,
+ breaker keys )'
+ `Draw the breaker in the stem then the element'
+define(`m4br_one',
+ `M4_S: last line.start
+ setkey_(`$4',lgth,brksiz_)dnl
+ line from M4_S to last line.end+vec_(-(m4lgth)*5/2,0)
+ sl_breaker(to rvec_(m4lgth,0),`$4')
+ $1(to rvec_((m4lgth)*3/2,0),`$3')
+ move to M4_S ')
+
+ `sl_eleminit_(linespec or (for zero length)
+ U|D|L|R|number [at location])'
+define(`sl_eleminit_',
+ `ifelse(regexp(`$1',^ *[UDLR0123456789]),-1,
+ `eleminit_(`$1',dimen_)',
+ `pushdef(`M4pos',`ifinstr(`$1',` at ',`patsubst(`$1',^.* at *)')')dnl
+ ifelse(M4pos,,,`move to M4pos;') setdir_(patsubst(`$1',` at.*'))
+ line invis from Here to Here popdef(`M4pos')')')
+
+# Two-terminal elements ###################################################
+
+ `sl_transformer(linespec,keys,
+ input breaker keys, output breaker keys)
+ keys:
+ type=I|S
+ (type=I) scale=expr; (default 1.5)
+ cycles=n; (default 4)
+ (type=S) body=shaded "color";
+ name=Body name;
+ (breaker default names BrI, BrO)'
+define(`sl_transformer',
+ `setkeys_(`$2',name::N; type:I:N; cycles:4:N; body::N; scale:1.5:; )dnl
+ ifelse(`$3'`$4',,
+ `ifinstr(m4type,S,
+ `source(`$1',G,,,m4body)',
+ `eleminit_(`$1'); m4atmp = rp_ang; m4slen = rp_len
+ define(`m4swd',`dimen_*3/16*m4scale')dnl
+ { line to rvec_((m4slen-m4swd)/2,0)
+ {ifelse(m4name,,SL_box,m4name): [ linewid = linewid*m4scale
+ {L1: inductor(to vec_(0,-m4cycles*dimen_/8),,m4cycles)}
+ {point_(m4atmp)
+ L2: inductor(from vec_(dimen_*3/16,-m4cycles*dimen_/8) \
+ to vec_(dimen_*3/16,0),,m4cycles)}
+ C2: last line.c; point_(m4atmp) ] with .L1.c at Here}
+ line from rvec_(m4swd,0) to rvec_((m4slen+m4swd)/2,0) }
+ line invis to rvec_(rp_len,0)') ',
+ `m4br_two(`sl_transformer',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO),
+ ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ')
+
+ `Two-terminal box'
+ `sl_ttbox(linespec,keys,breaker keys,breaker keys)
+ keys= lgth=expr; wdth=expr; box=attributes;
+ supp=additional rotbox commands; name=Body name;
+ text="text";
+ (breaker default names BrI, BrO)'
+define(`sl_ttbox',
+ `setkeys_(`$2',`lgth:dimen_*3/4; wdth:dimen_*3/4;
+ name::N; box::N; text::N; supp::N')dnl
+ ifelse(`$3'`$4',,
+ `eleminit_(`$1')
+ {line to rvec_((rp_len-m4lgth)/2,0)
+ {ifelse(m4name,,,m4name:)rotbox(m4lgth,m4wdth,m4box,,m4supp) \
+ with .W at Here }
+ {ifelse(m4text,,,`{m4text at rvec_(m4lgth/2,0)}') }
+ line from rvec_(m4lgth,0) to rvec_((rp_len+m4lgth)/2,0)}
+ line invis to rvec_(rp_len,0) ',
+ `m4br_two(`sl_ttbox',`$1',`$2',m4brk_(`$3',BrI),m4brk_(`$4',BrO),
+ ifelse(`$3',,,I)`'ifelse(`$4',,,O))') ')
+
+define(`m4brk_',`ifelse(`$1',,,
+ `ifelse(`$1',C,,`$1',O,box=fill 0,`$1')`'ifelse(`$2',,,;name=`$2')')')
+
+ `sl_rectifier(ttbox args)'
+define(`sl_rectifier',
+ `sl_ttbox(`$@')
+ { line from last [].Line.ne to last [].Line.sw
+ AC: ACsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R)
+ DC: DCsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ')
+
+ `sl_inverter(ttbox args)'
+define(`sl_inverter',
+ `sl_ttbox(`$@')
+ { line from last [].Line.ne to last [].Line.sw
+ DC: DCsymbol(at last [].C+(-m4lgth/6, m4wdth/4),,,R)
+ AC: ACsymbol(at 2nd last [].C+( m4lgth/6,-m4wdth/4),,,R) } ')
+
+ `sl_breaker(linespec, type=[A|C][D]; ttbox keys)
+ C is for curved breaker
+ D is for sl_drawout'
+define(`sl_breaker',
+ `setkeys_(`$2',`lgth:brksiz_; wdth:brksiz_; name::N; type::N')dnl
+ ifinstr(m4type,C,
+ `ifinstr(m4type,D,
+ `m4ch_two(`cbreaker',`$1')',
+ `ifelse(m4name,,,m4name:) cbreaker(`$1')')',
+ `ifinstr(m4type,D,
+ `m4ch_two(`sl_ttbox',`$1',lgth=m4lgth;wdth=m4wdth;`$2';name=Br)',
+ `sl_ttbox(`$1',lgth=m4lgth;wdth=m4wdth;`$2')') ') ')
+
+ `sl_reactor(linespec,keys,breaker keys,breaker keys)
+ keys=
+ diam=expr,
+ (Default breaker names BrI and BrO)'
+define(`sl_reactor',
+ `setkeys_(`$2',`diam:sourcerad_*4/3; type::N')dnl
+ ifelse(`$3'`$4',,
+ `eleminit_(`$1')
+ { line to rvec_(rp_len/2,0) then to rvec_(rp_len/2,-m4diam/2); round
+ arc rad m4diam/2 cw from Here to rvec_(m4diam/2,m4diam/2) \
+ with .c at rvec_(0,m4diam/2); round
+ line to rvec_(rp_len/2-m4diam/2,0) }
+ {[ box invis ht m4diam wid m4diam ] at rvec_(rp_len/2,0)}
+ line invis to rvec_(rp_len,0) ',
+ `m4br_two(`sl_reactor', `$1', lgth=m4diam*2;`$2',
+ m4brk_(`$3',BrI),m4brk_(`$4',BrO),ifelse(`$3',,,I)`'ifelse(`$4',,,O))')')
+
+ `sl_busbar( linespec, nports, keys )
+ Labels P1, P2 ... Pnports are defined on the line.
+ keys: line=line attributes;
+ port=D; (dotted ports)
+ The bus extends beyond the first and last points
+ by dimen_/5 which can be redefined as
+ line=chop -(expr)'
+define(`sl_busbar',
+ `define(`m4npoints',`ifelse(`$2',,2,`$2')')dnl
+ setkeys_(`$3',`line:thick 1.6 chop -dimen_/5:N; port::N')dnl
+ [ tmp_ang = rp_ang
+ eleminit_(`$1',(m4npoints-1)*dimen_)
+ Start: last line.start; End: last line.end
+ for_(1,m4npoints,1,
+ `P`'m4x: (m4x-1)/(m4npoints-1) between Start and End dnl
+ ifinstr(m4port,D,` ;dot(at P`'m4x)')')
+ Line: line from Start to End m4line
+ Start: last line.start; End: last line.end
+ point_(tmp_ang) ] ')
+
+ `sl_drawout(linespec, keys, R)
+ Drawout (i.e. plugin) chevron element;
+ keys: type=T; (truncated leads)
+ lgth=expr; (body size)
+ wdth=expr;
+ name=Name; (body name)
+ line= line attributes (e.g. thick 2)
+ arg3=R reverse direction'
+define(`sl_drawout',
+ `setkeys_(`$2',`lgth:drosiz_; wdth:drosiz_; type::N; name::N; line::N')dnl
+ eleminit_(`$1',ifelse(m4type,T,m4lgth))
+ ifelse(`$3',R,`{M4ds: Here; move to last line.end; rp_ang = rp_ang+pi_')
+ {line to rvec_(rp_len/2,0)
+ ifelse(m4name,,,m4name:) [
+ S: Here; {line from rvec_(-m4lgth/2,m4wdth/2) to Here then
+ to rvec_(-m4lgth/2,-m4wdth/2) m4line }
+ E: rvec_(m4lgth/2,0); line from rvec_(0,m4wdth/2) to E then
+ to rvec_(0,-m4wdth/2) m4line ] with .S at Here
+ ifelse(m4type,T,,
+ line from last [].E to last [].E+vec_((rp_len-m4lgth)/2,0))}
+ ifelse(`$3',R,`rp_ang = rp_ang-pi_; move to M4ds}')
+ line invis to rvec_(rp_len,0) ')
+
+# Two-terminal utilities ##################################################
+
+ `Breakers in the input and output lines:'
+ `m4br_two(`2-term element macroname in quotes',
+ linespec, body keys,
+ input breaker keys,
+ output breaker keys,
+ I|O|IO)'
+ `(Default breaker names are BrI and BrO)'
+define(`m4br_two',
+ `define(`m4il',`ifinstr(`$6',I,`setkey_(`$4',lgth,brksiz_) m4lgth',0)')dnl
+ define(`m4ol',`ifinstr(`$6',O,`setkey_(`$5',lgth,brksiz_) m4lgth',0)')dnl
+ define(`m4bl',`setkey_(`$3',lgth,dimen_*4/3) m4lgth')dnl
+ eleminit_(`$2',dimen_*3)
+ M4start: Here; M4end: last line.end
+ M4cc: last line.c+vec_(((m4il*3/2)-(m4ol*3/2)),0)
+ M4ii: M4cc+vec_(-min((m4bl/2+m4il/2),distance(M4start,M4cc)-m4il),0)
+ line from M4start to ifinstr(`$6',I,
+ `M4ii+vec_(-m4il,0); sl_breaker(to M4ii,`$4';name=BrI)',M4ii)
+ M4oi: M4cc+vec_(min((m4bl/2+m4ol/2),distance(M4end,M4cc)-m4ol),0)
+ $1(from M4ii to M4oi,`$3')
+ ifinstr(`$6',O,`sl_breaker(to M4oi+vec_(m4ol,0),`$5';name=BrO)')
+ line to M4end
+ line invis from M4start to M4end ')
+
+ `Chevrons in the input and output lines:'
+ `m4ch_two(`2-term element macroname in quotes',
+ linespec, body keys,
+ input breaker keys,
+ output breaker keys,
+ I|O|IO)'
+define(`m4ch_two',
+ `define(`m4bl',`setkey_(`$3',lgth,dimen_*3/8) m4lgth')dnl
+ eleminit_(`$2',dimen_*3)
+ M4start: Here; M4end: last line.end
+ M4elem: $1(to rvec_(m4bl+2*drosiz_,0) with .c at last line.c,`$3')
+ sl_drawout(from last line.start-vec_(drosiz_,0) to last line.start,type=T,R)
+ line from last line.start to M4start
+ sl_drawout(from M4elem.end to M4elem.end+vec_(drosiz_,0),type=T)
+ line to M4end
+ line invis from M4start to M4end')
+
+# Composite elements ###################################################
+
+ `sl_ct( at position, stem length, U|D|L|R|expr,
+ scale=expr) (default scale is 1.5)'
+define(`sl_ct',
+ `[ setdir_(`$3'); setkey_(`$4',scale,1.5); linewid = linewid*m4scale
+ L: inductor(to vec_(2*dimen_/8,0),,2)
+ stemlen = ifelse(`$2',,dimen_/5,`$2')
+ line from L.start to L.start+vec_(0,-stemlen)
+ Ts: Here
+ line from L.end to L.end+vec_(0,-stemlen)
+ Te: Here
+ line from L.c to L.c+vec_(0,-stemlen)
+ Tc: Here
+ resetdir_ ] with .L.c at ifelse(`$1',,Here,patsubst(`$1',^ *at *)) ')
+
+# #######################################################################
+
+divert(0)dnl
diff --git a/graphics/circuit_macros/examples/svg/SchottkySVG.m4 b/graphics/circuit_macros/examples/svg/SchottkySVG.m4
index 68a7037eb5..51e21bc291 100644
--- a/graphics/circuit_macros/examples/svg/SchottkySVG.m4
+++ b/graphics/circuit_macros/examples/svg/SchottkySVG.m4
@@ -1,5 +1,5 @@
-% SchottkySVG.m4
.PS
+# SchottkySVG.m4
# 4-input positive NAND: the Schottky option for transistors (TI TTL data book)
cct_init(svg_font(sans-serif,11bp__,1bp__))
diff --git a/graphics/circuit_macros/examples/svg/ex01SVG.m4 b/graphics/circuit_macros/examples/svg/ex01SVG.m4
index b8787d1539..dd22dd8494 100644
--- a/graphics/circuit_macros/examples/svg/ex01SVG.m4
+++ b/graphics/circuit_macros/examples/svg/ex01SVG.m4
@@ -16,13 +16,13 @@ Timer: [
define(`elen_',`linewid')
Vs: dot
down_
- variable(`resistor(,E); llabel(,svg_norm(1 M`'svg_ohm))');
- resistor(,E); llabel(,svg_norm(100 k`'svg_ohm))
+ variable(`resistor(,,E); llabel(,svg_norm(1 M`'svg_ohm))');
+ resistor(,,E); llabel(,svg_norm(100 k`'svg_ohm))
capacitor(,E); llabel(svg_norm(220 svg_micro`'F))
Zero: dot
dot(at Vs+(elen_*4/3,0))
- resistor(,E); llabel(,svg_norm(33 k`'svg_ohm))
+ resistor(,,E); llabel(,svg_norm(33 k`'svg_ohm))
line to (Here,Zero) chop 0 chop elen_
C2: capacitor; llabel(svg_norm(0.1 svg_micro`'F))
dot
@@ -40,7 +40,7 @@ R: dot
B: buzzer(,,C) with .In3 at Here
line from B.In1 to (R,B.In1)
reversed(`diode',to (Here,Vs),LE); "red" at last line.c+(elen_/2,0)
- resistor(down_ elen_ from R,E); llabel(,svg_norm(470 svg_ohm))
+ resistor(down_ elen_ from R,,E); llabel(,svg_norm(470 svg_ohm))
diode(to (Here,Zero),LE); {"green" wid 0.4 at last line.c+(elen_*2/3,0)}
line to Zero chop 0 chop -elen_
line up_ (Vs.y-Here.y)/3
diff --git a/graphics/circuit_macros/examples/svg/examplesSVG.htmx b/graphics/circuit_macros/examples/svg/examplesSVG.htmx
index 22ab9f9c42..ec9847b32e 100644
--- a/graphics/circuit_macros/examples/svg/examplesSVG.htmx
+++ b/graphics/circuit_macros/examples/svg/examplesSVG.htmx
@@ -51,9 +51,9 @@ ifinstr(`$3',y,,`<hr>')')
--------------------------------------------------------------------- -->
<BODY>
-<table cellpadding="0" cellspacing="0" width="700px" border="0" align="center" >
-<tr>
-<td>
+<table cellpadding="0" cellspacing="0"
+ width="700px" border="0" align="center" ><tr><td>
+
<H2>SVG Circuit_macros examples, Version XXX</H2>
<hr>
@@ -193,7 +193,6 @@ There are a number of other issues:
and
https://www.toptal.com/designers/htmlarrows/math/
-->
-<hr width="100%" align="left">
<table cellpadding="2" cellspacing="0" width="75%" >
<tr>
<td width="10%"> m4tt svg_alpha</g> <td align="left"> changecom(,)&`#'945;changecom(`#')
@@ -253,6 +252,7 @@ There are a number of other issues:
<td width="10%"> m4tt svg_rparen</g> <td align="left"> changecom(,)&`#'41;changecom(`#')
<td width="10%"> m4tt svg_circ</g> <td align="left"> changecom(,)&`#'710;changecom(`#')
<td width="10%"> m4tt svg_deg</g> <td align="left"> changecom(,)&`#'176;changecom(`#')
+<td width="10%"> m4tt svg_grave</g> <td align="left"> changecom(,)&`#'96;changecom(`#')
</tr>
</table>
<table cellpadding="2" cellspacing="0" width="75%" >
@@ -262,7 +262,6 @@ There are a number of other issues:
<td width="8%"> m4tt svg_thinsp</g> <td width="50px" align="left"> |changecom(,)&`#'8201;changecom(`#')|
</tr>
</table>
-<hr width="100%" align="left">
</ul>
<li> Inkscape: It may be efficient to define elements by macro and to
@@ -301,7 +300,7 @@ There are a number of other issues:
<hr>
cfig(ResistorsSVG,
- Resistors, showing some variations)
+ Resistors, showing some variations and the ebox)
cfig(CapacitorsSVG,
Capacitors)
@@ -309,9 +308,6 @@ cfig(CapacitorsSVG,
cfig(InductorsSVG,
Inductors)
-cfig(MoreTableSVG,
- Some other two-terminal elements)
-
cfig(DiodesSVG,
Diodes: a m4tt`'K</g> in the second argument draws an open
arrowhead)
@@ -319,34 +315,37 @@ cfig(DiodesSVG,
cfig(EmarrowsSVG,
Radiation arrows)
+cfig(VariableSVG,
+ Arrows and marks for showing variability)
+
cfig(SourcesSVG,
Sources and source-like elements)
-cfig(VariableSVG,
- Arrows and marks indicating variability)
-
cfig(AmpTableSVG,
Macros m4tt`'amp`,' delay</g>`,' and m4tt`'integrator</g>)
cfig(FusesSVG,
Macros m4tt`'fuse</g> and m4tt`'cbreaker</g>)
-cfig(SwitchesSVG,
- The switch macros; m4tt`'switch(`,'`,'`,'L|B|D)</g> is a wrapper
- for m4tt`'lswitch</g>`,' m4tt`'bswitch</g>`,' and m4tt`'dswitch</g>)
+cfig(MoreTableSVG,
+ Additional two-terminal elements)
cfig(GroundsSVG,
Ground symbols)
+cfig(SwitchesSVG,
+ The switch macros; m4tt`'switch(`,'`,'`,'L|B|D)</g> is a wrapper
+ for m4tt`'lswitch</g>`,' m4tt`'bswitch</g>`,' and m4tt`'dswitch</g>)
+
cfig(AntennasSVG,
Antenna symbols)
-cfig(AudioSVG,
- Audio elements)
-
cfig(OpampSVG,
The opamp)
+cfig(AudioSVG,
+ Audio elements)
+
cfig(XformSVG,
The transformer element`,' drawing direction down)
@@ -438,9 +437,6 @@ cfig(ex18SVG,
(illustrating m4tt`'opamp`,' diode`,' resistor`,' ground`,'</g>
and labels))
-cfig(MCSVG,
- A three-phase switched AC-AC converter and a DC-DC converter)
-
cfig(ex10SVG,
Non-planar graph and bistable circuit
(illustrating the m4tt`'crossover</g> macro and colored elements))
@@ -448,6 +444,9 @@ cfig(ex10SVG,
cfig(ThreeSVG,
Three-phase oscillator)
+cfig(MCSVG,
+ A three-phase switched AC-AC converter and a DC-DC converter)
+
cfig(ex17SVG,
A repetitive network created by Pic looping and
a skewed circuit used to test the macro m4tt`'parallel_</g>)
@@ -506,18 +505,18 @@ cfig(lcctSVG,
"An Approach to Drawing Circuit Diagrams for Text Books`,'"
Tugboat (12)1`,' March 1991`,' pp. 66-69)
-cfig(UNOSVG,
- An Arduino UNO circuit adapted and redrawn)
- <!--
- m4tt`'https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf</g>
- -->
-
cfig(TubediagsSVG,
Electron-tube diagrams: a few bottom-view base diagrams`,'
a generic triode test circuit`,' and a 25-watt audio amplifier adapted
from F. Langford-Smith`,' <i>Radiotron Designers Handbook</i>`,' fourth
edition`,' Harrison`,' NJ: Radio Corporation of America`,' 1952)
+cfig(UNOSVG,
+ An Arduino UNO circuit adapted and redrawn)
+ <!--
+ m4tt`'https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf</g>
+ -->
+
cfig(sfgSVG,
Signal-flow graphs)
@@ -533,7 +532,7 @@ cfig(DecoderSVG,
cfig(ex21SVG,
Some flip-flops)
-cfig(MultiplexerSVG,
+cfig(MultiplexerSVGfor showing
Multiplexer)
cfig(DemultiplexerSVG,
@@ -555,7 +554,7 @@ cfig(AlogixSVG,
The function tree is drawn`,' then a row or column of inputs`,' then
the connections. The default result is on the left`,'
a custom element at the top`,' and a tree of gates only is shown
- on the right. THe lower examples illustrate the L`,' R`,' and V options.)
+ on the right.)
cfig(ABlogixSVG,
The m4tt`'Autologix</g> macro can draw inputs on the left but
@@ -617,21 +616,23 @@ cfig(ex09SVG,
specifies the arc to be dimensioned and the second argument is
the outward radial offset of the dimension arrow arc.)
-cfig(PlateSVG,
- Dimensioning with tolerances according to ASME Y14.5)
+cfig(ex05SVG,
Use of m4tt`'darrow</g> and m4tt`'Darc</g>)
-cfig(ex05SVG,
+cfig(PlateSVG,
+ Dimensioning with tolerances according to ASME Y14.5)
Use of m4tt`'darrow</g> and m4tt`'Darc</g>)
cfig(LoglogSVG,
A graph drawn using the pic language)
cfig(GeometrySVG,
- A plane geometry example`,' and an illustration of a Lyapunov function)
+ Plane geometry examples and an illustration of a Lyapunov function)
+<!--
#cfig(LyapSVG,
# Illustrating a Lyapunov function)
+-->
cfig(randomSVG,
Testing random numbers)
diff --git a/graphics/circuit_macros/examples/svg/tstSVG.htmx b/graphics/circuit_macros/examples/svg/tstSVG.htmx
index 65425998fc..ccb14e00b8 100644
--- a/graphics/circuit_macros/examples/svg/tstSVG.htmx
+++ b/graphics/circuit_macros/examples/svg/tstSVG.htmx
@@ -5,63 +5,131 @@
<meta http-equiv="Content-Style-Type" content="text/css">
<!--meta http-equiv="Content-Script-Type" content="text/javascript"-->
<TITLE>SVG Examples: Circuit_macros Version XXX</TITLE>
+<meta name="keywords" content="HTML"
+content='Circuit elements, basic circuits, logic circuits and other diagrams,
+electric circuits, resistor, capacitor, inductor, diode, sources, amplifier,
+integrator, fuse, switch, antenna, opamp, transformer, relay, contact, jack,
+plug, FET, UJT, thyristor, bipolar transistor, nport, windings, timer,
+optical isolator, rectifier, bistable, oscillator, CMOS, MOSFET, power supply,
+NAND gate, controlled source, synchronous machine, digital circuit, signal-flow
+graph, latch, decoder, flipflop, full adder, logic diagram, crossbar switch,
+dimensioning, control system, graph, RGB colors, recursion, binary tree,
+flowcharts, picture overlay, ASME Y14.5' >
+
<style type="text/css">
</style>
+<link rel="shortcut icon" href="../Circuit_macros.ico" type="image/x-icon" />
</HEAD>
-<BODY>
-<H2>SVG Circuit_macros examples, Version XXX</H2>
-<hr>
+<!-- ---------------------------------------------------------------------
+define(`ifinstr',`ifelse(`$2',,`$1',index(`$1',`$2'),-1,
+ `ifinstr(shift(shift(shift($@))))',`$3')')
-<p>
- These diagrams are in .svg format.
- <A HREF="examples.pdf">Pdf</A>
- and
- <A HREF="examples.html">png</A>
- versions are also available.
- The PDF equivalent can be found in examples.pdf of the distribution.
-</p>
- <p>
- Click on the link to view the source of each diagram.
-</p>
-<hr>
+define(`m4tt',`<g style="font-family:monospace">')
define(`cfig',`
<p>
-<!--[if lt IE 9]><embed src="$1.svg" sinclude($1.siz)><![endif]-->
+
+<!--[if lte IE 8]><embed src="$1.svg" sinclude($1.siz)><![endif]-->
<!--[if gte IE 9]>
-<object data="$1.svg" sinclude($1.siz) type="image/svg+xml" class="img">
+<object dx="4" data="$1.svg" sinclude($1.siz) type="image/svg+xml" class="img">
</object> <![endif]-->
<!--[if !IE]><!-->
<object data="$1.svg" sinclude($1.siz) type="image/svg+xml" class="img">
- </object> <!--<![endif]-->
+ </object> <![endif]-->
+
+<br><br>
+ifelse(`$2',,,`
+<a href="$1.txt" TYPE="text/plain" TARGET="_blank" alt="$1">$1.m4:</a>
+`$2' changecom(,)&`#'8194;changecom(`#')')
-<br>
-<a href="$1.txt" TYPE="text/plain" TARGET="_blank">$1.m4</a>
</p>
-<hr>')
+ifinstr(`$3',y,,`<hr>')')
-define(`m4tt',`<g style="font-family:monospace">')
+--------------------------------------------------------------------- -->
-<!--
-<embed pluginspage="http://www.adobe.com/svg/viewer/install/" />
--->
+<BODY>
+<table cellpadding="0" cellspacing="0"
+ width="700px" border="0" align="center" ><tr><td>
+<H2>SVG Circuit_macros examples, Version XXX</H2>
+<hr>
+
+<p>
+ This file shows diagrams in .svg format;
+ <A HREF="examples.html">png</A>
+ versions are also available.
+ The PDF equivalent can be found in examples.pdf of the distribution.
+</p>
+
+<p>
+The diagrams shown below have been adapted from the Circuit_macros
+examples in order to test the svg output of dpic. Generating svg line
+art is straightforward, but TeX, LaTeX, and related word
+processors do not produce svg. Either less-sophisticated text formatting
+must be employed or an
+ <A HREF="https://en.wikibooks.org/wiki/LaTeX/Export_To_Other_Formats">
+ intermediate format</A>
+such as pdf can be
+produced, followed by an additional processing step to convert to svg.
+Two possibilities for the latter are
+ <A HREF="https://www.ctan.org/pkg/dvisvgm">dvisvgm</A>
+and
+ <A HREF="https://github.com/dawbarton/pdf2svg">pdf2svg</A> although
+there may be font-related issues for some diagrams.
+<br>
+Many circuit and similar diagrams intended for the web do not
+require sophisticated labels, however; the examples shown below might
+be representative.
+</p>
<p>
-These diagrams have been adapted from the Circuit_macros examples in
-order to test the <em>experimental</em> svg output of dpic.
-Generating the line art is relatively straightforward, but
-the labeling is not created by a text processor and must, therefore, be
-more basic.
+ Click on the link to view the source of each diagram.
</p>
+<hr>
<p>
+There are a number of other issues:
<ul>
+ <li> Embedding .svg files in html documents with the &lt;embed&gt; or
+ &lt;object&gt; tag seems to be a perennial issue.
+ <li> This file has been tested mainly by using Firefox.
+ <li> The Adobe reader apparently requires a line of the form
+ <br> &lt;embed src="figure.svg" width="x" height="y" type="image/svg+xml"
+ /&gt;
+ This means that the html file has to contain dimension
+ information for each figure, whereas Firefox can
+ determine the figure size
+ from the &lt;svg ... object. Currently, dpic includes a comment line
+ giving reasonable dimensions in pixels but this has to be insterted into
+ the &lt;embed or &lt;object line. A makefile does it easily but
+ otherwise this could be tedious.
+ <li> The default font face is not specified in all of these diagrams but is
+ inherited from the enclosing document, so the appearance of labels can
+ differ depending on the browser. Some of these diagrams set the font at
+ the beginning of the diagram source.
+ <li> The &lt;svg tag may require modification
+ from the default used for this test. Dpic might be modified to
+ allow the generation of custom headers but that has not been done.
+ <li> Diagrams such as these contain text labels
+ that have to be treated differently from the LaTeX-compatible versions.
+ Apparently there is no direct way to know the bounding box of arbitrary svg
+ text.
+ <!-- text, as discussed
+ <a href="http://www.aditus.nu/jpgraph/jpg_svg.php" TARGET="_blank">here,</a>
+ for example. -->
+ Consequently, text placement is approximate and may require
+ manual adjustment.
+ Rather than patch the original source files for svg production, edited copies
+ have been used. The configuration file svg.m4 read by m4
+ prior to libcct.m4 contains the following macros defined for svg.
+ Others could be defined to exercise some of the media capabilties of svg.
+ They are subject to change:
<ul>
<li>
m4tt`'svg_font(</g>font-face,nominal size[:dptextratio],textoffset,
dpic commands`'m4tt)</g>:
+ Change font face, size, textratio and dpic textoffset parameters.
Change font face and dpic m4tt`'textht</g>, m4tt`'dptextratio</g>,
and m4tt`'textoffset</g> parameters.
If arg4 is blank, the font is changed and
@@ -95,10 +163,10 @@ more basic.
for setting larger or smaller text size, default 100
<li>m4tt svg_sub(</g>text, size percent, y displ, x displ`'m4tt)</g>:
subscript
- <li>m4tt svg_sup(</g>text, size percent, y displ, x displ`'m4tt)</g>:
- superscript
<li>m4tt svg_ul(</g>text`'m4tt)</g>: underlined text
<li>m4tt svg_ol(</g>text`'m4tt)</g>: overlined text
+ <li>m4tt svg_sup(</g>text, size percent, y displ, x displ`'m4tt)</g>:
+ superscript
<li>m4tt svg_hat(</g>character`'m4tt)</g>: circumflex-accented character
<li>m4tt svg_frac(</g>numerator[:wid], denominator[:wid]`'m4tt)</g>:
basic fraction, wid in drawing units
@@ -119,81 +187,104 @@ more basic.
<li>m4tt svgLinkString</g> as above but for strings attached to objects
<li> Greek and other symbols:
-<table cellpadding="0" cellspacing="0" width="100%" >
+<!--
+ Reference:
+ https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
+ and
+ https://www.toptal.com/designers/htmlarrows/math/
+ -->
+<table cellpadding="2" cellspacing="0" width="75%" >
<tr>
-<td width="8%"> m4tt svg_alpha</g> <td align="left"> changecom(,)&`#'945;changecom(`#')
-<td width="8%"> m4tt svg_beta</g> <td align="left"> changecom(,)&`#'946;changecom(`#')
-<td width="8%"> m4tt svg_Gamma</g> <td align="left"> changecom(,)&`#'915;changecom(`#')
-<td width="8%"> m4tt svg_gamma</g> <td align="left"> changecom(,)&`#'947;changecom(`#')
-<td width="8%"> m4tt svg_Delta</g> <td align="left"> changecom(,)&`#'916;changecom(`#')
-<td width="8%"> m4tt svg_delta</g> <td align="left"> changecom(,)&`#'948;changecom(`#')
+<td width="10%"> m4tt svg_alpha</g> <td align="left"> changecom(,)&`#'945;changecom(`#')
+<td width="10%"> m4tt svg_beta</g> <td align="left"> changecom(,)&`#'946;changecom(`#')
+<td width="10%"> m4tt svg_Gamma</g> <td align="left"> changecom(,)&`#'915;changecom(`#')
+<td width="10%"> m4tt svg_gamma</g> <td align="left"> changecom(,)&`#'947;changecom(`#')
+<td width="10%"> m4tt svg_Delta</g> <td align="left"> changecom(,)&`#'916;changecom(`#')
+<td width="10%"> m4tt svg_delta</g> <td align="left"> changecom(,)&`#'948;changecom(`#')
<td width="10%"> m4tt svg_epsilon</g> <td align="left"> changecom(,)&`#'949;changecom(`#')
-<td width="8%"> m4tt svg_zeta</g> <td align="left"> changecom(,)&`#'950;changecom(`#')
+<td width="10%"> m4tt svg_zeta</g> <td align="left"> changecom(,)&`#'950;changecom(`#')
+</tr>
<tr>
-<td width="8%"> m4tt svg_eta</g> <td align="left"> changecom(,)&`#'951;changecom(`#')
-<td width="8%"> m4tt svg_Theta</g> <td align="left"> changecom(,)&`#'920;changecom(`#')
-<td width="8%"> m4tt svg_theta</g> <td align="left"> changecom(,)&`#'952;changecom(`#')
-<td width="8%"> m4tt svg_iota</g> <td align="left"> changecom(,)&`#'953;changecom(`#')
-<td width="8%"> m4tt svg_kappa</g> <td align="left"> changecom(,)&`#'954;changecom(`#')
-<td width="8%"> m4tt svg_Lambda</g> <td align="left"> changecom(,)&`#'923;changecom(`#')
-<td width="8%"> m4tt svg_lambda</g> <td align="left"> changecom(,)&`#'955;changecom(`#')
-<td width="8%"> m4tt svg_mu</g> <td align="left"> changecom(,)&`#'956;changecom(`#')
+<td width="10%"> m4tt svg_eta</g> <td align="left"> changecom(,)&`#'951;changecom(`#')
+<td width="10%"> m4tt svg_Theta</g> <td align="left"> changecom(,)&`#'920;changecom(`#')
+<td width="10%"> m4tt svg_theta</g> <td align="left"> changecom(,)&`#'952;changecom(`#')
+<td width="10%"> m4tt svg_iota</g> <td align="left"> changecom(,)&`#'953;changecom(`#')
+<td width="10%"> m4tt svg_kappa</g> <td align="left"> changecom(,)&`#'954;changecom(`#')
+<td width="10%"> m4tt svg_Lambda</g> <td align="left"> changecom(,)&`#'923;changecom(`#')
+<td width="10%"> m4tt svg_lambda</g> <td align="left"> changecom(,)&`#'955;changecom(`#')
+<td width="10%"> m4tt svg_mu</g> <td align="left"> changecom(,)&`#'956;changecom(`#')
+</tr>
<tr>
-<td width="8%"> m4tt svg_nu</g> <td align="left"> changecom(,)&`#'957;changecom(`#')
-<td width="8%"> m4tt svg_Xi</g> <td align="left"> changecom(,)&`#'926;changecom(`#')
-<td width="8%"> m4tt svg_xi</g> <td align="left"> changecom(,)&`#'958;changecom(`#')
-<td width="8%"> m4tt svg_Pi</g> <td align="left"> changecom(,)&`#'928;changecom(`#')
-<td width="8%"> m4tt svg_pi</g> <td align="left"> changecom(,)&`#'960;changecom(`#')
-<td width="8%"> m4tt svg_rho</g> <td align="left"> changecom(,)&`#'961;changecom(`#')
-<td width="8%"> m4tt svg_Sigma</g> <td align="left"> changecom(,)&`#'931;changecom(`#')
-<td width="8%"> m4tt svg_sigma</g> <td align="left"> changecom(,)&`#'963;changecom(`#')
+<td width="10%"> m4tt svg_nu</g> <td align="left"> changecom(,)&`#'957;changecom(`#')
+<td width="10%"> m4tt svg_Xi</g> <td align="left"> changecom(,)&`#'926;changecom(`#')
+<td width="10%"> m4tt svg_xi</g> <td align="left"> changecom(,)&`#'958;changecom(`#')
+<td width="10%"> m4tt svg_Pi</g> <td align="left"> changecom(,)&`#'928;changecom(`#')
+<td width="10%"> m4tt svg_pi</g> <td align="left"> changecom(,)&`#'960;changecom(`#')
+<td width="10%"> m4tt svg_rho</g> <td align="left"> changecom(,)&`#'961;changecom(`#')
+<td width="10%"> m4tt svg_Sigma</g> <td align="left"> changecom(,)&`#'931;changecom(`#')
+<td width="10%"> m4tt svg_sigma</g> <td align="left"> changecom(,)&`#'963;changecom(`#')
+</tr>
<tr>
-<td width="8%"> m4tt svg_tau</g> <td align="left"> changecom(,)&`#'964;changecom(`#')
+<td width="10%"> m4tt svg_tau</g> <td align="left"> changecom(,)&`#'964;changecom(`#')
<td width="10%"> m4tt svg_upsilon</g> <td align="left"> changecom(,)&`#'965;changecom(`#')
-<td width="8%"> m4tt svg_Phi</g> <td align="left"> changecom(,)&`#'934;changecom(`#')
-<td width="8%"> m4tt svg_phi</g> <td align="left"> changecom(,)&`#'966;changecom(`#')
-<td width="8%"> m4tt svg_chi</g> <td align="left"> changecom(,)&`#'967;changecom(`#')
-<td width="8%"> m4tt svg_Psi</g> <td align="left"> changecom(,)&`#'936;changecom(`#')
-<td width="8%"> m4tt svg_psi</g> <td align="left"> changecom(,)&`#'968;changecom(`#')
-<td width="8%"> m4tt svg_Omega</g> <td align="left"> changecom(,)&`#'937;changecom(`#')
+<td width="10%"> m4tt svg_Phi</g> <td align="left"> changecom(,)&`#'934;changecom(`#')
+<td width="10%"> m4tt svg_phi</g> <td align="left"> changecom(,)&`#'966;changecom(`#')
+<td width="10%"> m4tt svg_chi</g> <td align="left"> changecom(,)&`#'967;changecom(`#')
+<td width="10%"> m4tt svg_Psi</g> <td align="left"> changecom(,)&`#'936;changecom(`#')
+<td width="10%"> m4tt svg_psi</g> <td align="left"> changecom(,)&`#'968;changecom(`#')
+<td width="10%"> m4tt svg_Omega</g> <td align="left"> changecom(,)&`#'937;changecom(`#')
+</tr>
<tr>
-<td width="8%"> m4tt svg_omega</g> <td align="left"> changecom(,)&`#'969;changecom(`#')
-<td width="8%"> m4tt svg_micro</g> <td align="left"> changecom(,)&`#'956;changecom(`#')
-<td width="8%"> m4tt svg_ohm</g> <td align="left"> changecom(,)&`#'937;changecom(`#')
-<td width="8%"> m4tt svg_lt</g> <td align="left"> changecom(,)&`#'60;changecom(`#')
-<td width="8%"> m4tt svg_gt</g> <td align="left"> changecom(,)&`#'62;changecom(`#')
-<td width="8%"> m4tt svg_leq</g> <td align="left"> changecom(,)&`#'8804;changecom(`#')
-<td width="8%"> m4tt svg_geq</g> <td align="left"> changecom(,)&`#'8805;changecom(`#')
-<td width="8%"> m4tt svg_prime</g> <td align="left"> changecom(,)&`#'8242;changecom(`#')
+<td width="10%"> m4tt svg_omega</g> <td align="left"> changecom(,)&`#'969;changecom(`#')
+<td width="10%"> m4tt svg_micro</g> <td align="left"> changecom(,)&`#'956;changecom(`#')
+<td width="10%"> m4tt svg_ohm</g> <td align="left"> changecom(,)&`#'937;changecom(`#')
+<td width="10%"> m4tt svg_lt</g> <td align="left"> changecom(,)&`#'60;changecom(`#')
+<td width="10%"> m4tt svg_gt</g> <td align="left"> changecom(,)&`#'62;changecom(`#')
+<td width="10%"> m4tt svg_leq</g> <td align="left"> changecom(,)&`#'8804;changecom(`#')
+<td width="10%"> m4tt svg_geq</g> <td align="left"> changecom(,)&`#'8805;changecom(`#')
+<td width="10%"> m4tt svg_prime</g> <td align="left"> changecom(,)&`#'8242;changecom(`#')
+</tr>
<tr>
-<td width="8%"> m4tt svg_backsl</g> <td align="left"> changecom(,)&`#'92;changecom(`#')
-<td width="8%"> m4tt svg_pound</g> <td align="left"> changecom(,)&`#'35;changecom(`#')
-<td width="8%"> m4tt svg_comma</g> <td align="left"> changecom(,)&`#'44;changecom(`#')
-<td width="8%"> m4tt svg_lparen</g> <td align="left"> changecom(,)&`#'40;changecom(`#')
-<td width="8%"> m4tt svg_rparen</g> <td align="left"> changecom(,)&`#'41;changecom(`#')
-<td width="8%"> m4tt svg_emsp</g> <td align="left"> |changecom(,)&`#'8195;changecom(`#')|
-<td width="8%"> m4tt svg_ensp</g> <td align="left"> |changecom(,)&`#'8194;changecom(`#')|
-<td width="8%"> m4tt svg_thinsp</g> <td align="left"> |changecom(,)&`#'8201;changecom(`#')|
+<td width="10%"> m4tt svg_backsl</g> <td align="left"> changecom(,)&`#'92;changecom(`#')
+<td width="10%"> m4tt svg_pound</g> <td align="left"> changecom(,)&`#'35;changecom(`#')
+<td width="10%"> m4tt svg_comma</g> <td align="left"> changecom(,)&`#'44;changecom(`#')
+<td width="10%"> m4tt svg_lparen</g> <td align="left"> changecom(,)&`#'40;changecom(`#')
+<td width="10%"> m4tt svg_rparen</g> <td align="left"> changecom(,)&`#'41;changecom(`#')
+<td width="10%"> m4tt svg_circ</g> <td align="left"> changecom(,)&`#'710;changecom(`#')
+<td width="10%"> m4tt svg_deg</g> <td align="left"> changecom(,)&`#'176;changecom(`#')
+<td width="10%"> m4tt svg_grave</g> <td align="left"> changecom(,)&`#'96;changecom(`#')
+</tr>
+</table>
+<table cellpadding="2" cellspacing="0" width="75%" >
<tr>
-<td width="8%"> m4tt svg_circ</g> <td align="left"> |changecom(,)&`#'710;changecom(`#')|
-<td width="8%"> m4tt svg_deg</g> <td align="left"> |changecom(,)&`#'176;changecom(`#')|
+<td width="8%"> m4tt svg_emsp</g> <td width="50px" align="left"> |changecom(,)&`#'8195;changecom(`#')|
+<td width="8%"> m4tt svg_ensp</g> <td width="50px" align="left"> |changecom(,)&`#'8194;changecom(`#')|
+<td width="8%"> m4tt svg_thinsp</g> <td width="50px" align="left"> |changecom(,)&`#'8201;changecom(`#')|
+</tr>
</table>
</ul>
<li> Inkscape: It may be efficient to define elements by macro and to
- place them using a WYSIWYG graphics editor. A draft page intended
+ place them using a wysiwyg graphics editor. A draft page intended
for Inkscape is included. A reasonable variety of elements is defined
- but should be customized for particular applications.
+ but many more could be added and they should be customized for
+ particular applications. Adjustments may also have to be made to
+ obtain the proper snap-to actions.
<li> Link experiments: Click on the resistor or source of quickSVG
to go to external
files in new windows. Click on "n-port" in NportSVG to replace the diagram
and then "back" to return.
- <li> Some of the assumptions used to create this draft may be naive. Comments
- are welcome.
+ <li> Some of the assumptions used to create this draft may be
+ na&`#'239;ve.
+ Comments are welcome.
</ul>
+
<hr>
cfig(XXXXX)
+</td>
+</tr>
+</table>
</BODY>
</HTML>
diff --git a/graphics/circuit_macros/examples/xfig/xfiglib.fig b/graphics/circuit_macros/examples/xfig/xfiglib.fig
index 081aef7471..521b4d0307 100644
--- a/graphics/circuit_macros/examples/xfig/xfiglib.fig
+++ b/graphics/circuit_macros/examples/xfig/xfiglib.fig
@@ -6,7 +6,7 @@ Letter
100.00
Single
-2
-# dpic version 2021.05.15 option -x for Fig 3.2
+# dpic version 2021.08.01 option -x for Fig 3.2
1200 2
6 0 0 3975 5025
6 0 0 3975 5025
@@ -135,12 +135,14 @@ Single
6 3300 75 3450 675
2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2
3375 675 3375 425
+6 3300 325 3450 425
2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2
3425 425 3325 425
2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 6
3375 400 3300 400 3300 350 3450 350 3450 400 3375 400
2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2
3425 325 3325 325
+-6
2 1 0 1 0 -1 0 -1 -1 0 0 0 0 0 0 2
3375 325 3375 75
-6