From a8defee70e0584a8e7dffa017ae41d58fd45996e Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 31 May 2024 03:01:27 +0000 Subject: CTAN sync 202405310301 --- graphics/circuit_macros/examples/extras/Ant.m4 | 30 ------ .../circuit_macros/examples/extras/Asymptotes.m4 | 93 +++++++++++++++++ graphics/circuit_macros/examples/extras/Birds.m4 | 36 +++++++ .../circuit_macros/examples/extras/Bistable.m4 | 35 +++++++ graphics/circuit_macros/examples/extras/Brace.m4 | 115 +++++++++++++++++++++ graphics/circuit_macros/examples/extras/Ccurve.m4 | 14 --- graphics/circuit_macros/examples/extras/Chaos.m4 | 39 +++++++ graphics/circuit_macros/examples/extras/Chuck.m4 | 6 -- .../circuit_macros/examples/extras/ClassDAmp.m4 | 6 +- graphics/circuit_macros/examples/extras/Cruller.m4 | 67 ------------ .../circuit_macros/examples/extras/Cylinder.m4 | 43 -------- graphics/circuit_macros/examples/extras/HSV.m4 | 26 +++++ .../circuit_macros/examples/extras/Highgain.m4 | 10 +- graphics/circuit_macros/examples/extras/Koch.m4 | 33 ------ graphics/circuit_macros/examples/extras/Makefile | 44 ++++---- .../examples/extras/Parallel-series.m4 | 15 +++ graphics/circuit_macros/examples/extras/Person.m4 | 45 ++++++++ .../circuit_macros/examples/extras/README_extras | 2 +- .../circuit_macros/examples/extras/Rotellipse.m4 | 20 ++++ .../circuit_macros/examples/extras/SampleFlow.m4 | 8 +- graphics/circuit_macros/examples/extras/Spec555.m4 | 56 ++++++++++ .../circuit_macros/examples/extras/Squiggle.m4 | 26 +++++ graphics/circuit_macros/examples/extras/Venus.m4 | 74 +++++++++++++ graphics/circuit_macros/examples/extras/birds.m4 | 36 ------- .../circuit_macros/examples/extras/bistable.m4 | 35 ------- graphics/circuit_macros/examples/extras/brace.m4 | 115 --------------------- graphics/circuit_macros/examples/extras/chaos.m4 | 39 ------- graphics/circuit_macros/examples/extras/ex17.m4 | 43 ++++++++ graphics/circuit_macros/examples/extras/hsv.m4 | 26 ----- graphics/circuit_macros/examples/extras/person.m4 | 45 -------- .../circuit_macros/examples/extras/rotellipse.m4 | 20 ---- .../circuit_macros/examples/extras/squiggle.m4 | 26 ----- graphics/circuit_macros/examples/extras/venus.m4 | 74 ------------- 33 files changed, 661 insertions(+), 641 deletions(-) delete mode 100644 graphics/circuit_macros/examples/extras/Ant.m4 create mode 100644 graphics/circuit_macros/examples/extras/Asymptotes.m4 create mode 100644 graphics/circuit_macros/examples/extras/Birds.m4 create mode 100644 graphics/circuit_macros/examples/extras/Bistable.m4 create mode 100644 graphics/circuit_macros/examples/extras/Brace.m4 delete mode 100644 graphics/circuit_macros/examples/extras/Ccurve.m4 create mode 100644 graphics/circuit_macros/examples/extras/Chaos.m4 delete mode 100644 graphics/circuit_macros/examples/extras/Cruller.m4 delete mode 100644 graphics/circuit_macros/examples/extras/Cylinder.m4 create mode 100644 graphics/circuit_macros/examples/extras/HSV.m4 delete mode 100644 graphics/circuit_macros/examples/extras/Koch.m4 create mode 100644 graphics/circuit_macros/examples/extras/Parallel-series.m4 create mode 100644 graphics/circuit_macros/examples/extras/Person.m4 create mode 100644 graphics/circuit_macros/examples/extras/Rotellipse.m4 create mode 100644 graphics/circuit_macros/examples/extras/Spec555.m4 create mode 100644 graphics/circuit_macros/examples/extras/Squiggle.m4 create mode 100644 graphics/circuit_macros/examples/extras/Venus.m4 delete mode 100644 graphics/circuit_macros/examples/extras/birds.m4 delete mode 100644 graphics/circuit_macros/examples/extras/bistable.m4 delete mode 100644 graphics/circuit_macros/examples/extras/brace.m4 delete mode 100644 graphics/circuit_macros/examples/extras/chaos.m4 create mode 100644 graphics/circuit_macros/examples/extras/ex17.m4 delete mode 100644 graphics/circuit_macros/examples/extras/hsv.m4 delete mode 100644 graphics/circuit_macros/examples/extras/person.m4 delete mode 100644 graphics/circuit_macros/examples/extras/rotellipse.m4 delete mode 100644 graphics/circuit_macros/examples/extras/squiggle.m4 delete mode 100644 graphics/circuit_macros/examples/extras/venus.m4 (limited to 'graphics/circuit_macros/examples/extras') diff --git a/graphics/circuit_macros/examples/extras/Ant.m4 b/graphics/circuit_macros/examples/extras/Ant.m4 deleted file mode 100644 index f4a22226a2..0000000000 --- a/graphics/circuit_macros/examples/extras/Ant.m4 +++ /dev/null @@ -1,30 +0,0 @@ -.PS -# Ant.m4 (Langton's ant) -# https://tex.stackexchange.com/questions/361838/how-to-create-a-langtons-ant-in-latex/361891 -# https://en.wikipedia.org/wiki/Langton%27s_ant -gen_init -NeedDpicTools - picwid = 5 - D: (0,0); DD: (1,0); t[D] = 0 - minx = 0; miny = 0; maxx = 0; maxy = 0 - for i = 0 to 10500 do { - if (t[D]%2) == 0 then { DD: (-DD.y,DD.x) } else { DD: (DD.y,-DD.x) } - t[D] += 1 - D: D+DD - if D.x > maxx then { maxx = D.x; for y = miny to maxy do { t[maxx,y] = 0 }} \ - else { if D.x < minx then { - minx = D.x; for y = miny to maxy do { t[minx,y] = 0 }}} - if D.y > maxy then { maxy = D.y; for x = minx to maxx do { t[x,maxy] = 0 }} \ - else { if D.y < miny then { - miny = D.y; for x = minx to maxx do { t[x,miny] = 0 }}} - } - boxwid = picwid/(maxx-minx) - boxht = picwid/(maxy-miny) - if boxht > boxwid then { boxht = boxwid } else { boxwid = boxht } - circlerad = boxht/2 - hue = 240; val = 1 - for i = minx to maxx do { for j = miny to maxy do { - if t[i,j]!=0 then { sat = (t[i,j]%20)/20 - hsvtorgb(hue,sat,val,r,g,b) - circle colored rgbstring(r,g,b) at (-i,j)*boxwid } }} -.PE diff --git a/graphics/circuit_macros/examples/extras/Asymptotes.m4 b/graphics/circuit_macros/examples/extras/Asymptotes.m4 new file mode 100644 index 0000000000..4afd0f5758 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Asymptotes.m4 @@ -0,0 +1,93 @@ +.PS +# Asymptotes.m4 +# https://tex.stackexchange.com/questions/706340/create-an-asymptotes-summary-diagram-for-a-function +gen_init + +definergbcolor(armygreen,0.29,0.33,0.13) +definergbcolor(vlightgray,0.95,0.95,0.95) +boxrad = 7bp__ + +define(`greenbox',`box wid 90bp__ \ + outlined "armygreen!90" shaded "armygreen!90" \ + "{\color{white} `$1'}" ') + +define(`graybox',`box thick 0.4 outlined "gray" shaded "vlightgray" \ + `$1'') + + changequote(,) command "\newcommand{\eace}{\'e} + \newcommand{\squote}{\char39} + \newcommand{\dequation}{d'\'equation}" + changequote(`,) + +foreach_(`txt',`L`'m4Lx: graybox(wid 72bp__ ht 130 bp__ \ + "\parbox{72bp}{\begin{centering} + {\sf txt \\ \vfill\vbox{}} + \end{centering}}") + ifelse(m4Lx,6,,`move 10bp__')', + + `$(C_f)$ admet\\ Une asymptote\\ horizontale\\ \dequation:\\ + $y = a$\\ au voisinage\\ de $\infty$', + + `$(C_f)$ admet\\ Une asymptote\\ oblique\\ \dequation:\\ + $y = ax+b$\\ au voisinage\\ de $\infty$', + + `\hbox{}\vspace*{0.5\baselineskip} + $(C_f)$ admet\\ Une branche\\ parabolique\\ de direction\\ + la droite\\ \dequation:\\ + $y = ax$\\ au voisinage\\ de $\infty$', + + `$(C_f)$ admet\\ Une branche\\ parabolique\\ de direction\\ + l\squote{}axe des\\ ordonn\eace{}s\\ au voisinage\\ de $\infty$', + + `$(C_f)$ admet\\ Une branche\\ parabolique\\ de direction\\ + l\squote{}axe des\\ abscisses\\ au voisinage\\ de $\infty$', + + `\vspace*{1ex}$(C_f)$ admet\\ Une \\ asymptote\\ verticale\\ + \dequation:\\[1ex] + $x = a$\\ \hbox{}\hfill\hbox{}') + + M: [ M1: graybox(wid 105bp__ \ + "$\lim\limits_{x\rightarrow\infty} [f(x)-ax] = b$") + move 3bp__ + M2: graybox(wid 105bp__ \ + "$\lim\limits_{x\rightarrow\infty} [f(x)-ax] = \infty$") + ] with .s at ((L2.x+L4.x)/2,L2.n.y+boxht) + + U:[ foreach_(`txt',`U`'m4Lx:graybox(wid 100bp__ ifelse(m4Lx,1,`+20bp__') "txt") + ifelse(m4Lx,4,,`move 2bp__')', + `$\lim\limits_{x\rightarrow\infty} [f(x)-(ax{+}b)] = 0$', + `\(\lim\limits_{x\rightarrow\infty} \frac{f(x)}{x} = + \raisebox{-0.5ex}{$a \atop {(a \neq 0)}$}\)', + `\(\lim\limits_{x\rightarrow\infty} \frac{f(x)}{x} = \infty \)', + `\(\lim\limits_{x\rightarrow\infty} \frac{f(x)}{x} = 0 \)') + ] with .s at ((L1.x+L6.x)/2,M.n.y+boxht) + + T1: greenbox($\lim\limits_{x\rightarrow\infty} f(x) = a$) \ + with .s at (L1.x,U.n.y+boxht) + T2: greenbox($\lim\limits_{x\rightarrow\infty} f(x) = \infty$) \ + with .s at ((L1.x+L6.x)/2,T1.s.y) + T3: greenbox($\lim\limits_{x\rightarrow a} f(x) = \infty$) \ + with .e at (L6.e.x,T2.y) + + linethick_(1) + arrow from (U.w.x-5bp__,T1.s.y) down T1.s.y-L1.n.y + A: (T2.w.x,T2.s.y+boxrad); B1: U.U1.n+(boxht,0) + move to A; arcto((B1,A),B1,boxrad*3/2); arrow to B1 + A: (U.U3.w.x+boxrad,T2.s.y); arrow from A to (A,U.U3.n) + B2: (1/2 between M.M1.e and M.M2.w,U.U2.n) + line from A+(-5bp__,0) down_ 10bp__ then left 10bp__ + arcto((B2,Here),B2,boxrad*3/2); arrow to B2 + B3: (L5.e.x-2*boxrad,U.U4.n.y) + line from A+( 5bp__,0) down_ 10bp__ then right_ 10 bp__ + arcto((B3,Here),B3,boxrad*3/2); arrow to B3 + arrow from (B3,U.U4.s) to (B3,L5.n) + arrow from (U.U4.e.x+5bp__,T3.s.y) down T3.s.y-L6.n.y + line from U.U2.s+(-5bp__,0) down_ 10bp__ then left_ 10bp__ + arcto((M.M1.n,Here),M.M1.n,boxrad*3/2); arrow to M.M1.n + arrow from (Here,M.M1.s) down M.M1.s.y-L2.n.y + line from U.U2.s+( 5bp__,0) down_ 10bp__ then right_ 10bp__ + arcto((M.M2.n,Here),M.M2.n,boxrad*3/2); arrow to M.M2.n + arrow from (L3.e.x-boxrad*3/2,M.M2.s.y) down M.M2.s.y-L3.n.y + arrow from (M.M2.e.x+5bp__,U.U3.s.y) down U.U3.s.y-L4.n.y + arrow from (M.w.x-5bp__,U.U1.s.y) down U.U1.s.y-L2.n.y +.PE diff --git a/graphics/circuit_macros/examples/extras/Birds.m4 b/graphics/circuit_macros/examples/extras/Birds.m4 new file mode 100644 index 0000000000..4b42ea35af --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Birds.m4 @@ -0,0 +1,36 @@ +.PS +# Birds.m4 +gen_init + +scale = 50 +linethick = 2*linethick + +define bird {[ + line shaded "$1" from (0,0) to \ + (10,-5) to (19,8) to (35,7) to (38,-12)+(0,2) to (60,0) to\ + (75,23) to (80,40) to (52,37)+(2,2) to (74,50) to (52,50) to \ + (60,60) to (38,48)+(0,2) to (35,67) to (19,68) to (10,55) to \ + (0,60) to (-8,50) to (14,50) to (-8,37)+(2,2) to (20,40) to \ + (15,23) to (0,0) +E: (80,40) +W: (20,40) +N: (19,68) +S: (19,8) + line outlined "gray" from (35,15) down 10 right 25 + line outlined "gray" from (40,20) right 25 down 8 + line outlined "gray" from (42,25) right 28 down 6 + line outlined "gray" from (40,30) right 32 down 4 + circle outlined "gray" rad 1 at (1,55) + circle outlined "gray" rad 4 at (24,55) +]} + + ncols = 4 + nrows = 4 + right + for i=0 to nrows-1 do { + for j=0 to ncols-1 do { move to (j*60,-i*60) + if (i+j)%2==0 then { bird(black) } else { bird(white) } + } + } + +.PE diff --git a/graphics/circuit_macros/examples/extras/Bistable.m4 b/graphics/circuit_macros/examples/extras/Bistable.m4 new file mode 100644 index 0000000000..ac49023863 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Bistable.m4 @@ -0,0 +1,35 @@ +.PS +# `bistable.m4' +cct_init # Default initialization + + up_ +rgbdraw(1,0,0, +Q1: bi_tr(,R) # Q1 upward with base to the right + llabel(,Q_1) ) # Label to left of last [] +rgbdraw(0,0,1, +Q2: bi_tr with .C at Q1.C+(elen_*7/4,0) # Q2 with base to left + rlabel(,Q_2) ) + + ground(at Q1.E) + ground(at Q2.E) + + line right_ dimen_/3 from Q1.B # Extend the base conductors +B1: Here + line left_ dimen_/3 from Q2.B +B2: Here + + resistor(up_ elen_*0.75 from Q1.C); llabel(,"$R_L$" wid 0.16) # Load resistors + line to (Q2.C,Here) "$V_{\hbox{cc}}$" below + resistor(down_ to Q2.C); llabel(,R_L) + + move to Q1.C+(0,dimen_/5) + { resistor(right_ to (B1,Here)); llabel(,R_1) +X: line to B2 } # Label the line to be jumped + resistor(from (Q2.C,Here) left_ to (B2,Here)); rlabel(,R_1) + crossover(to B1,R,X) + + resistor(down_ elen_*0.75); rlabel(,R_2) # Bias resistors + {"$-V_{\hbox{cc}}$" rjust} + line to (B2,Here) + resistor(up_ to B2); rlabel(,R_2) +.PE diff --git a/graphics/circuit_macros/examples/extras/Brace.m4 b/graphics/circuit_macros/examples/extras/Brace.m4 new file mode 100644 index 0000000000..b0089fe96d --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Brace.m4 @@ -0,0 +1,115 @@ +.PS +# brace.m4 +gen_init +NeedDpicTools + +divert(-1) + `bracket(linespec, end depth, + thickness, end thickness, attributes) + Square bracket along linespec + default depth is linewid/5 + attributes = eg + thick 0.4 outlined "string" shaded "string" + (default black)' +define(`bracket',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + M4brS: last line.start; M4brE: last line.end + [ brdepth = ifelse(`$2',,linewid/5,`($2)') + brthick = ifelse(`$3',,brdepth/6,`($3)') + endthick = ifelse(`$4',,brthick/3,`($4)') + define(`m4brackattribs', + `ifelse(`$5',,`thick 0.4 shaded rgbstring(0,0,0)',`$5')')dnl + {line m4brackattribs \ + from M4brS+vec_(0,brdepth) to M4brS+vec_(0,brdepth+brthick) \ + then to M4brE+vec_(0,brdepth+brthick) \ + then to M4brE \ + then to M4brE+vec_(-endthick,0) \ + then to M4brE+vec_(-endthick,brdepth) \ + then to M4brS+vec_( endthick,brdepth) \ + then to M4brS+vec_( endthick,0) \ + then to M4brS \ + then to M4brS+vec_(0,brdepth) } + S: M4brS + ] with .S at Here') + + `brace(linespec,depth,arm thickness,attributes) + Curly brace along linespec + default depth is linewid/5 + attributes = eg + thick 0.4 outlined "string" shaded "string" + (default black)' +define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + M4brS: last line.start; M4brE: last line.end + [ brdepth = ifelse(`$2',,linewid/5,`$2') + brthick = ifelse(`$3',,brdepth/6,`$3') + define(`m4braceattribs', + `ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl + tension = 0.55 + halfwid = distance(M4brS,M4brE) + smallrad = brdepth-brthick + bigrad = brdepth+brthick + for sgn=1 to -1 by -2 do { + S: rvec_(sgn*halfwid/2,0) + A: S+vec_(0,smallrad/2) + B: vec_(0,smallrad/2) + T: vec_(0,brdepth) + C: vec_(0,bigrad/2) + D: vec_(sgn*halfwid/2,bigrad/2) + {spline tension m4braceattribs \ + from S to tension between S and A \ + then to tension between A-vec_(sgn*bigrad/2,0) and A \ + then to A-vec_(sgn*bigrad/2,0) \ + then to B+vec_(sgn*bigrad/2,0) \ + then to tension between B+vec_(sgn*bigrad/2,0) and B \ + then to tension between T and B \ + then to T \ + then to tension between T and C \ + then to tension between C+vec_(sgn*bigrad/2,0) and C \ + then to C+vec_(sgn*bigrad/2,0) \ + then to D-vec_(sgn*bigrad/2,0) \ + then to tension between D-vec_(sgn*bigrad/2,0) and D \ + then to tension between S and D \ + then to S } + } + E: (0,0) +] with .E at 0.5 between M4brS and M4brE') +divert(0)dnl + + del = 0.2 + maxht = 2 + minht = 0.3 + n = 16 + hmax = 360 +R1: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + brace(from ( -i*del,-y/2) up y,,,thick 0.4 shaded rgbstring(r,g,b)) + brace(from ((i+1)*del, y/2) down y,,,thick 0.4 \ + outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] +R2: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + brace(from ( -i*del,-y/2) up y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ + shaded rgbstring(r,g,b)) + brace(from ((i+1)*del, y/2) down y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ + outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] with .n at R1.s+(0,-0.2) +R3: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + bracket(from ( -i*del,-y/2) up y, 5bp__+x*20bp__, 2bp__+x*13bp__,, + thick 0.4 shaded rgbstring(r,g,b)) + bracket(from ((i+1)*del, y/2) down y, 5bp__+x*20bp__, 2bp__+x*13bp__,, + thick 0.4 outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] with .n at R2.s+(0,-0.2) + +.PE diff --git a/graphics/circuit_macros/examples/extras/Ccurve.m4 b/graphics/circuit_macros/examples/extras/Ccurve.m4 deleted file mode 100644 index 6f3b537aac..0000000000 --- a/graphics/circuit_macros/examples/extras/Ccurve.m4 +++ /dev/null @@ -1,14 +0,0 @@ -.PS -# Ccurve.m4 -gen_init -scale = 1.5 -# Gosper C curve - -`define' c_curve {if $3==0 then { continue by ($1,$2) } else { - c_curve( ($1-$2)/2, ($1+$2)/2, $3-1) - c_curve( ($1+$2)/2, ($2-$1)/2, $3-1)}} - -line from 0,4 to 0,4 -c_curve(0,4,10) - -.PE diff --git a/graphics/circuit_macros/examples/extras/Chaos.m4 b/graphics/circuit_macros/examples/extras/Chaos.m4 new file mode 100644 index 0000000000..17ae070e58 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Chaos.m4 @@ -0,0 +1,39 @@ +.PS +# chaos.m4 +# Example simulation of chaos equations. +gen_init +scale = 10 +define(`FF',`dnl + `$4' = `$1'+dt*10*(-`$1'+`$2') + `$5' = `$2'+dt*(28*`$1'-`$2'-`$1'*`$3') + `$6' = `$3'+dt*(-8*`$3'/3+`$1'*`$2') ') +[ +x0 = 1 +y0 = 0 +z0 = 0 +dt = 0.005 +nN = 100 +for i = 1 to nN do { + for j = 1 to 8 do { + FF(x0,y0,z0,x1,y1,z1) + FF(x1,y1,z1,x2,y2,z2) + FF(x2,y2,z2,x3,y3,z3) + FF(x3,y3,z3,x4,y4,z4) + spline from x0,y0 to x1,y1 then to x2,y2 then to x3,y3 then to x4,y4 + x0 = x4; y0 = y4; z0 = z4 + } + } +arrow from (-15,0) to (15,0); "$x$" ljust +line up 1 from (10,0); "$ 10$" at last line.start below +line up 1 from (-10,0); "$-10$" at last line.start below +arrow from (0,-15) to (0,15); "$y$" above +line right 1 from (0,10); "$ 10$" at last line.start rjust +line right 1 from (0,-10); "$-10$" at last line.start rjust +"$ 0$" at (0,0) below rjust +] +`"\parbox{2.5in}{\begin{eqnarray*} + \dot{x}_1 & = & 10(-x_1+x_2)\\ + \dot{x}_2 & = & 28x_1-x_2-x_1x_3\\ + \dot{x}_3 & = & -8x_3/3+x_1x_2 + .\end{eqnarray*}}"' at last [].s below +.PE diff --git a/graphics/circuit_macros/examples/extras/Chuck.m4 b/graphics/circuit_macros/examples/extras/Chuck.m4 index df83a8ce0e..3d85390e80 100644 --- a/graphics/circuit_macros/examples/extras/Chuck.m4 +++ b/graphics/circuit_macros/examples/extras/Chuck.m4 @@ -216,11 +216,5 @@ dimension_thick r_dimen(from D[3]+(0,-14) right 35,0,35) r_dimen(from (0,D[3].y-14) right 35,0,35) -# arrow <- down 30 left 30 from D[3] chop 16/2 chop 0 then left 5 -# "16 DRILL 23 CBORE" rjust "4 HOLES" rjust - -# arrow <- from (-305/2,30.6+10+2) up 5 left 5 then up 13 -# s_box(SEE (A)) with .sw at Here+(-5pt__,2pt__) - command "}%" .PE diff --git a/graphics/circuit_macros/examples/extras/ClassDAmp.m4 b/graphics/circuit_macros/examples/extras/ClassDAmp.m4 index b8e845cf06..93f73a17cb 100644 --- a/graphics/circuit_macros/examples/extras/ClassDAmp.m4 +++ b/graphics/circuit_macros/examples/extras/ClassDAmp.m4 @@ -9,7 +9,7 @@ Q1: mosfet(down_ dimen_*5/4,R,TFSDdPyQdB) dot(at Q1.S) { line up_ dimen_/4 dot(,,1); "ifsvg(`svg_it(V)svg_sub(DD)',`$V_{\hbox{\scriptsize DD}}$')" \ - at last [].n+(0,0.05) above } + at last [].e ljust } line left_ dimen_*2/3 SW: switch(left_ dimen_,`$1',D); ifelse(`$1',,`rlabel(,SW1)',`llabel(,SW2)') Q2: mosfet(up_ dimen_*5/4,,TFSDPyQuB) with .D at Q1.D @@ -27,7 +27,7 @@ T: dot; right_ ]') S1: String -S2: String(R) with .Q1.S at S1.Q2.D+(0,-2*elen_) +S2: String(R) with .Q1.S at S1.Q2.D+(0,-3/2*elen_) I1: line left_ dimen_/2 from S1.Comp.In1 sinusoid(dimen_/4,twopi_/(dimen_/2),-pi_/2,0,dimen_/2) \ with .Start at I1.end-(textoffset,0) @@ -51,7 +51,7 @@ NO: dot(at N.Out+(dimen_/12,0)) dot { line up_ dimen_/2; diode(to (NO,Here),Z); line to NO } { capacitor(down_ dimen_); ground(,T,S) - llabel(,iflatex(C_{\hbox{\scriptsize On}},ifsvg(svg_it(R)`'svg_sub(On)))) } + llabel(iflatex(C_{\hbox{\scriptsize On}},ifsvg(svg_it(R)`'svg_sub(On)))) } line dashed to (S1.SW,Here) arrow <-> dashed from S1.SW to S2.SW chop dimen_/4 diff --git a/graphics/circuit_macros/examples/extras/Cruller.m4 b/graphics/circuit_macros/examples/extras/Cruller.m4 deleted file mode 100644 index d2c215ae13..0000000000 --- a/graphics/circuit_macros/examples/extras/Cruller.m4 +++ /dev/null @@ -1,67 +0,0 @@ -.PS -# Cruller.m4 -threeD_init -NeedDpicTools -scale = 2.54 - -define(`lobe',`(sind(6*(`$1'))+4)/5*2.25') - - viewazimuth = 20 # Set view angles in degrees - viewelevation = 30 - setview(viewazimuth,viewelevation,0) - - dt = 3 # major angle degrees per facet - ds = 10 # minor angle degrees per facet - - tradius = 6 -define(`cruller',`rot3Dz((`$1')*dtor_, - sum3D(0,tradius,0,0,Rect_(lobe(`$2'+2*(`$1')),`$2')))') - -define(`tvisible',`dot3D(View3D, - cross3D(diff3D(cruller(`$1'+dt/2,`$2'),cruller(`$1',`$2')), - diff3D(cruller(`$1',`$2'+ds/2),cruller(`$1',`$2'))))') - - # create the arrays and sort - n = 0 - for t = dt to 360+dt/2 by dt do { - for s=ds/2 to 360.1 by ds do { - if tvisible(t,s) > -0.01 then { - n +=1 - t[n] = t - s[n] = s - d[n] = dot3D(cruller(t,s),view3D1,view3D2,view3D3) # view distance - ix[n] = n - } - } } -# prval(n) - dpquicksort(d,1,n,ix) - - # Background -Bne: (9,6) -Bsw: (-9,-6) -B: 0.5 between Bne and Bsw -iflatex(`line fill_(0.75) \ - from (Bsw,Bne) to Bsw then to (Bne,Bsw) then to Bne then to (Bsw,Bne)', - `ShadedPolygon((Bsw,Bne):Bsw:(Bne,Bsw):Bne,,-30, - 0,1,1,1, - .5,.1,.4,0, - 1,0,0,0) at B') - # draw the facets -thinlines_ -[ - rgbtohsv(0.6,0.4,0,h,s,v) - for i = 1 to n do { - tc = t[ix[i]]; sc = s[ix[i]] - SE: (Project(cruller(tc+dt/2,sc-ds/2))) - SW: (Project(cruller(tc-dt/2,sc-ds/2))) - NW: (Project(cruller(tc-dt/2,sc+ds/2))) - NE: (Project(cruller(tc+dt/2,sc+ds/2))) - f = ((dcosine3D(3,cruller(tc,sc))/2.25+1)/2)^2 - hsvtorgb(h,(1-f)*s,1,r,g,b) - line outlined rgbstring(r,g,b) shaded rgbstring(r,g,b) ifpdf( invis ) \ - from SE to SW then to NW then to NE then to SE } - ] at B - -thicklines_ - -.PE diff --git a/graphics/circuit_macros/examples/extras/Cylinder.m4 b/graphics/circuit_macros/examples/extras/Cylinder.m4 deleted file mode 100644 index abe9a9bac7..0000000000 --- a/graphics/circuit_macros/examples/extras/Cylinder.m4 +++ /dev/null @@ -1,43 +0,0 @@ -.PS -# Cylinder.m4 -gen_init(SIdefaults) # lengths are in mm - -define(`cylinder',`[ angle = ifelse(`$3',,20,`$3') - w = ifelse(`$1',,boxwid,`$1') - h = ifelse(`$2',,boxht,`$2') - B: ellipse wid w ht sind(angle)*w - S: box invis wid w ht h fill_(1) with .s at B - line from S.nw to S.sw - line from S.ne to S.se - T: ellipse wid w ht sind(angle)*w at B+(0,h) - ]') - -define Cylinder { [ dtor = atan2(1,0)/90 - if "$1"=="" then { w = boxwid } else { w = $1 } - if "$2"=="" then { h = boxht } else { h = $2 } - if "$3"=="" then { angle = 20 } else { angle = $3 } - B: ellipse wid w ht sin(angle*dtor)*w - S: box invis wid w ht h fill 1 with .s at B - line from S.nw to S.sw - line from S.ne to S.se - T: ellipse wid w ht sin(angle*dtor)*w at B+(0,h) - ] } - -M4: [ - cylinder - move - cylinder(,,15) - move - cylinder(3,50) - ] -"M4 macro" at last [].s below - -Pic: [ - Cylinder - move - Cylinder(,,15) - move - Cylinder(3,50) - ] with .w at M4.e+(5,0) -"pic macro" at last [].s below -.PE diff --git a/graphics/circuit_macros/examples/extras/HSV.m4 b/graphics/circuit_macros/examples/extras/HSV.m4 new file mode 100644 index 0000000000..662184dd7d --- /dev/null +++ b/graphics/circuit_macros/examples/extras/HSV.m4 @@ -0,0 +1,26 @@ +.PS +# hsv.m4 +gen_init +NeedDpicTools + +define grid { (($2)*boxwid,($1)*boxht) } +r = 0 +g = 0 +b = 1 +rgbtohsv(r,g,b,h,s,v) +nstep = 4 +{ for j=0 to nstep do { + sprintf("%g",j/nstep) at ((0.5+j)*boxwid,-boxht/2) below } } + { "S" at ((0.5+nstep/2)*boxwid, -boxht) } +{ for i=0 to nstep do { sprintf("%g",i/nstep) at (-boxht/3,(i)*boxht) } } + { "V" at (-boxht,(nstep/2)*boxht) \ + "or" \ + "L" } +right_ +for v = 0 to nstep do { + { for s = 0 to nstep do { hsvtorgb(h,s/nstep,v/nstep,r,g,b) + box shaded rgbstring(r,g,b) } } + move up_ boxht; right_ } + + +.PE diff --git a/graphics/circuit_macros/examples/extras/Highgain.m4 b/graphics/circuit_macros/examples/extras/Highgain.m4 index 06bc62985e..71cbc74a49 100644 --- a/graphics/circuit_macros/examples/extras/Highgain.m4 +++ b/graphics/circuit_macros/examples/extras/Highgain.m4 @@ -48,23 +48,23 @@ define(`vectorsize', [ R: darrow(right linewid,,,,,,|-) - { s_box($R$) dabove(at R.start+(5pt__,0)) } + { "$R$" dabove(at R.start+(5pt__,0)) } Sum: circle invis "$\sum$" darrow(right_ linewid*5/4) - { s_box($E$) dabove(at last line) } + { "$E$" dabove(at last line) } vectorsize(p,at 1/4 along_(last line)) Gain: shadebox(box "$G = \diag\mat{g_i}$" wid boxwid*1.5 ht boxht*0.75 ) darrow(,,,,,,!-) - { s_box($U^{\prime}$) dabove(at last line) } + { "$U^{\prime}$" dabove(at last line) } Compensator: shadebox(box wid boxwid*1.5 "\sl Compensator" "$K(s)$") darrow(right_ linewid*5/4,,,,,,!-) vectorsize(m,at 1/4 along_(last line)) - { s_box($U$) dabove(at last line) } + { "$U$" dabove(at last line) } Plant: shadebox(box "\sl Plant" "$H(s)$" ) dline(right_ linewid*3/4 from Plant.e,,,,!-) vectorsize(p,at last line) Y: dtee(R) - {s_box($Y$) dabove} + {"$Y$" dabove} darrow(right_ linewid*2/3,t) dline(down boxht from Y,t) diff --git a/graphics/circuit_macros/examples/extras/Koch.m4 b/graphics/circuit_macros/examples/extras/Koch.m4 deleted file mode 100644 index cb122c10b6..0000000000 --- a/graphics/circuit_macros/examples/extras/Koch.m4 +++ /dev/null @@ -1,33 +0,0 @@ -.PS -# Koch snowflake -gen_init - - leng = 4 - X: 3,5 - nsides = 3; rot[1] = 0; rot[2] = -120; rot[3] = -120 - depth=4 - - for i=1 to depth do { - for j=1 to nsides do { tmp[j] = rot[j] } - leng = leng/3 - k = 0 - for j=1 to nsides do { - rot[k+1] = tmp[j] - rot[k+2] = 60 - rot[k+3] = -120 - rot[k+4] = 60 - k += 4 - } - nsides = k - } - - a = 0 - line from X to X - for i=1 to nsides do { - a += rot[i] -# X: X+(Rect_(leng,a)) -# continue to X - continue by (Rect_(leng,a)) - } - -.PE diff --git a/graphics/circuit_macros/examples/extras/Makefile b/graphics/circuit_macros/examples/extras/Makefile index efc8a2b23e..a29b0a81fd 100644 --- a/graphics/circuit_macros/examples/extras/Makefile +++ b/graphics/circuit_macros/examples/extras/Makefile @@ -51,7 +51,7 @@ BOXDIMS = DVIPSOPTS = -G0 -t letter DIMFILE = $(DOC).dim -BS = tr '|' '\134' +TRSLASH = tr '|' '\134' # Might be needed (change latex commands to $(LTX) ) # LTX = latex --shell-escape @@ -62,13 +62,13 @@ XTRASRC=printf "|documentclass[11pt]{article}\n\ |usepackage{times,boxdims,siunitx,amssymb,tikz}\n\ |setlength{|textwidth}{8in} |setlength{|textheight}{10.5in}\n\ |setlength{|hoffset}{-2cm} |setlength{|voffset}{-3cm}\n\ -|begin{document}\n" | $(BS) +|begin{document}\n" | $(TRSLASH) PDFLTXSRC=printf "|documentclass[11pt]{standalone}\n\ |usepackage{times,boxdims,siunitx,amssymb,tikz,geometry}\n\ |geometry{paperwidth=15in,paperheight=14in,margin=1in}\n\ |pagestyle{empty}|thispagestyle{empty}\n\ -|begin{document}|noindent|input{"$*".tex}|end{document}\n" | $(BS) +|begin{document}|noindent|input{"$*".tex}|end{document}\n" | $(TRSLASH) LTXFILE=printf "|documentclass[11pt]{article}\n\ |usepackage[dvipsnames]{xcolor}\n\ @@ -81,7 +81,7 @@ LTXFILE=printf "|documentclass[11pt]{article}\n\ |newbox|graph\n\ |begin{document}\n\ |noindent|input{"$*".tex}|box|graph\n\ -|end{document}\n" | $(BS) +|end{document}\n" | $(TRSLASH) .SUFFIXES: .ps .dvi .tex .m4 .pic .eps .png .pdf .svg .tif .gif .m4.pic: @@ -158,33 +158,39 @@ LTXFILE=printf "|documentclass[11pt]{article}\n\ ######################################################################### -$(DOC).pdf: +$(DOC).pdf: texfiles @$(XTRASRC) > extras.tex touch extras.dim -for fl in `ls *.m4` ; do \ file=`basename $$fl .m4` ; \ - echo $$file.m4 ; \ - $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; \ - printf "\n\n|noindent|parbox{|textwidth}{\n" | $(BS) >> extras.tex ; \ - printf "|input{$$file.tex}\n" | $(BS) >> extras.tex ; \ + printf "\n\n|noindent|parbox{|textwidth}{\n" | $(TRSLASH) >> extras.tex; \ + printf "|input{$$file.tex}\n" | $(TRSLASH) >> extras.tex ; \ printf "\n $$file.m4\n}\n|vspace{|baselineskip}" \ - | sed -e 's/_/|_/g' | $(BS) >> extras.tex ; \ - done - printf "\n|end{document}\n" | $(BS) >> extras.tex - pdflatex extras - -for file in $(XBOXDIMS) ; do \ - rm -f $$file.tex ; \ - $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; \ + | sed -e 's/_/|_/g' | $(TRSLASH) >> extras.tex ; \ done + printf "\n|end{document}\n" | $(TRSLASH) >> extras.tex pdflatex extras +# -for file in $(XBOXDIMS) ; do \ +# rm -f $$file.tex ; \ +# $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; \ +# done +# pdflatex extras + +texfiles: + touch extras.dim + for fl in `ls *.m4` ; do \ + file=`basename $$fl .m4` ; \ + echo $$file.m4 ; \ + $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; done + touch texfiles $(DOC).ps: psmode $(DOC).dvi psmode: - printf "|usepackage{pstricks,pst-grad}\n" | $(BS) > mode.tex + printf "|usepackage{pstricks,pst-grad}\n" | $(TRSLASH) > mode.tex pdfmode: - printf "|usepackage{tikz}\n" | $(BS) > mode.tex + printf "|usepackage{tikz}\n" | $(TRSLASH) > mode.tex $(DOC).dvi: $(DOC).tex files.tex header.tex psmode touch $(DOC).dim @@ -208,4 +214,4 @@ tst1: dvips $(DVIPSOPTS) tst -o tst.ps clean: - rm -f *.ps *.pdf *.tex *.dim *.pic *.log *.dms *.aux *.svg + rm -f *.ps *.pdf *.tex *.dim *.pic *.log *.dms *.aux *.svg texfiles diff --git a/graphics/circuit_macros/examples/extras/Parallel-series.m4 b/graphics/circuit_macros/examples/extras/Parallel-series.m4 new file mode 100644 index 0000000000..fb20cc21eb --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Parallel-series.m4 @@ -0,0 +1,15 @@ +.PS +# parallel-series.m4 +# https://tex.stackexchange.com/questions/709074/how-to-plot-a-block-diagram-with-tikz +cct_init + + dot; line right_ dimen_/2 + parallel_( + parallel_( + `ebox(,wdth=0.2;text="$x_1$")', + `Sep=dimen_*3/4;ebox(,wdth=0.2;text="$x_2$")'), + Sep=dimen_;series_( + `ebox(,wdth=0.2;text="$x_3$")', + `ebox(,wdth=0.2;text="$x_4$")')) + line right_ dimen_/2; dot +.PE diff --git a/graphics/circuit_macros/examples/extras/Person.m4 b/graphics/circuit_macros/examples/extras/Person.m4 new file mode 100644 index 0000000000..4fdf09d387 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Person.m4 @@ -0,0 +1,45 @@ +.PS +# person.m4 +gen_init + +divert(-1) + `person( + hght=expr;wdth=expr;fill="colorname") + e.g. person(hght=1;fill="gray")' +define(`person', + `[ pushkeys_(`$1',hght:linewid;wdth:m4hght*2/5;fill:"black":N)dnl + bodywid = m4wdth/2 + bodyrad = bodywid/8 + bodyht = (m4hght - bodywid - bodywid/16 + bodyrad*2)/2 + tmplth = linethick; linethick = 0 + Head: circle diam bodywid colored m4fill + Body: box rad bodyrad ht bodyht wid bodywid colored m4fill \ + with .n at Head.s+(0,-Head.diam/16) + armwid = bodywid/3 + Armleft: box wid armwid rad armwid/2 ht Body.ht-bodyrad colored m4fill \ + with .w at Body.e + (armwid/2,0) + Armright: box same with .e at Body.w + (-armwid/2,0) + Legleft: box wid bodywid/2.5 rad armwid/2 ht Body.ht colored m4fill \ + with .n at (Body.w,Body.s)+(bodywid/5,bodyrad*2) + Legright: box same with .n at (Body.e,Body.s)+(-bodywid/5,bodyrad*2) + linethick_(tmplth) popdef(`m4hght',`m4wdth',`m4fill') ]') + +divert(0)dnl + + linewid = 3*linewid + movewid = 0.2 + + setrgb(0.54,0.81,0.94,babyblue) + person(fill="babyblue") + move + person(wdth=linewid*3/4;fill="babyblue") + move + person(wdth=linewid;fill="babyblue") + move + person + move + resetrgb + person(hght=1;fill="gray") + + line up linewid with .c at last [].e+(linewid/10,0) +.PE diff --git a/graphics/circuit_macros/examples/extras/README_extras b/graphics/circuit_macros/examples/extras/README_extras index 45074a49b2..ebef7cfcd1 100644 --- a/graphics/circuit_macros/examples/extras/README_extras +++ b/graphics/circuit_macros/examples/extras/README_extras @@ -11,4 +11,4 @@ often be done reasonably in several possible languages. This directory is assumed to be a subdirectory of the examples directory in order to include the necessary definition files. -Type "make" and, to clean up, "make clean". +Type "make" to create extras.pdf and, to clean up, "make clean". diff --git a/graphics/circuit_macros/examples/extras/Rotellipse.m4 b/graphics/circuit_macros/examples/extras/Rotellipse.m4 new file mode 100644 index 0000000000..a49ce308b3 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Rotellipse.m4 @@ -0,0 +1,20 @@ +.PS +# `rotellipse.m4' +gen_init + +[ + E: ellipse shaded "red" outlined "blue" + + A: rotellipse(1,1,outlined "red" shaded "blue") with .w at E.e + Point_(45) + B: rotellipse(,,dotted fill_(0.9)) + C: rotellipse(,,colored "red") with .s at last [].n + thinlines_ + showbox_(A) + showbox_(B) + showbox_(C) + thicklines_ + +] with .sw at 1,1 + +.PE diff --git a/graphics/circuit_macros/examples/extras/SampleFlow.m4 b/graphics/circuit_macros/examples/extras/SampleFlow.m4 index 077a0ba6e3..94e334c46a 100644 --- a/graphics/circuit_macros/examples/extras/SampleFlow.m4 +++ b/graphics/circuit_macros/examples/extras/SampleFlow.m4 @@ -2,11 +2,11 @@ # SampleFlow.m4 darrow_init -boxwid = 1.9 -boxht = 1.0 +boxwid = 1.15 +boxht = 0.6 linethick = 1.2 - define(`dlthick',0.25) + define(`dlthick',0.125) define(`dfillcolor',`0.7,0.7,0.7') define rbox {box rad boxht/10} @@ -17,7 +17,7 @@ linethick = 1.2 dleft darrow(to last box.w) } } - command "{\sf\huge" + command "{\sf" B1: rbox { "Sample" ljust indent "Acquisition" ljust } diff --git a/graphics/circuit_macros/examples/extras/Spec555.m4 b/graphics/circuit_macros/examples/extras/Spec555.m4 new file mode 100644 index 0000000000..713ccb2967 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Spec555.m4 @@ -0,0 +1,56 @@ +.PS +# Spec555.m4 +# https://tex.stackexchange.com/questions/64801/display-ics-with-circuitikz?rq=1 +log_init + +define(`spec555',`[ Chip: box wid 8*lg_pinsep ht 10*lg_pinsep fill_(0.9) + command "{\scriptsize\sf" + P1: "1" at 3/4 below rjust; "GND" above + P5: "5" at Chip.s below rjust ; "CTRL" above + P2: "2" at 1/8 above rjust; "TRG" ljust + P6: "6" at 3/8 above rjust; "THR" ljust + P7: "7" at 7/8 above rjust; "DIS" ljust + P3: "3" at Chip.e above ljust ; "OUT" rjust + P4: "4" at 3/4 above rjust; "\phantom{M}RESET" below + P8: "8" at Chip.n above rjust ; "Vcc" below + "NE-555" at Chip.c "TIMER" + command "}%" + line left dimen_ from P7; X:dot + { R1:resistor(up_ P7.y-P6.y); rlabel(,\SI{68}{\kilo\ohm}); dot } + R2:resistor(down_ P7.y-P6.y); llabel(,\SI{68}{\kilo\ohm}); dot; {line to P6} + line to (Here,P2); SW: dot; {line to P2} + line from P8 to (P8,R1.end); dot ]') + + command "{\small\sf" + T1: spec555; "U1" at T1.Chip.nw above ljust + T2: spec555 with .Chip.w at T1.Chip.e+(2.5*dimen_,0) + "U2" at T2.Chip.nw above ljust + {line left_ dimen_/2 from (T1.X,T1.P7); diode(down_ T1.P7.y-T1.P6.y) + rlabel(,\shortstack{D1\\1N4148}) + line to (T1.X,Here); dot} + capacitor(down_ elen_ from T1.SW,E+); llabel(,\SI{10}{\micro\farad}); dot + dot(at Here-(dimen_/2,0),,1); G: dot(,,1); "GND" rjust at G.w + capacitor(from T1.P5 to (T1.P5,G),E+); rlabel(,\SI{0.01}{\nano\farad}); dot + line from T1.P1 to (T1.P1,G); dot + Vcc: dot(at (G,T1.R1.end),,1); "Vcc" rjust at Vcc.w + dot(at (T1.P4,Vcc)); line to T1.P4 + line right_ dimen_/2 from T1.P3; + R3: resistor(down_ to (Here,T2.s-(0,dimen_/4))); llabel(,\SI{10}{\kilo\ohm}) + line to (T2.P5,Here) then to T2.P5 + dot(at (T2.X,G)); ground + reversed(`capacitor',up_ to (Here,T2.P5),E+); rlabel(,\SI{100}{\nano\farad}) + line to (Here,T2.P2) + line from T2.P1 to (T2.P1,G); dot + line from T2.P4 to (T2.P4,Vcc) then to Vcc chop 0 chop dotrad_ + dot(at (T2.X,T2.R1.end)+(0,dimen_/2),,1); {line to T2.R1.end chop dotrad_} + "$+$\SI{5}{\volt} to $+$\SI{15}{\volt}" at last [].n above + capacitor(right_ dimen_ from T2.P3,C); llabel(,\SI{100}{\micro\farad}) + Pot1: potentiometer(down_ (Here.y-G.y)/2) with .Start at Here + "Rx" at Pot1.T1 ljust + Sp: speaker(R,,,fill_(0.9)) with .In5 at Pot1.End + "1" above rjust at Sp.In5; "2" below rjust at Sp.In7 + "\shortstack{E1\\Speaker}" at Sp.In2 rjust + line from Sp.In7 to (Sp.In7,G) then to G chop 0 chop dotrad_ + command "}%" + +.PE diff --git a/graphics/circuit_macros/examples/extras/Squiggle.m4 b/graphics/circuit_macros/examples/extras/Squiggle.m4 new file mode 100644 index 0000000000..671ae2addd --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Squiggle.m4 @@ -0,0 +1,26 @@ +.PS +# squiggle.m4 +gen_init + +divert(-1) +dnl Should this macro be in libgen.m4 or would that be just adding clutter? + + `squiggle(linespec, + amplitude,wavelength,attributes)' + `squiggly line (sinusoid), e.g. + squiggle(up_ 1 right_ 2,,,outlined "red")' +define(`squiggle',`rpoint_(ifelse(`$1',,linewid,`$1')) + m4dist = lin_leng(last line) + m4cycles = int(m4dist/(ifelse(`$3',,0.25*scale,`$3'))+0.5) + define(`squiggleampl',`ifelse(`$2',,0.04*scale,`$2')')dnl + define(`squigglefreq',`(twopi_*m4cycles/m4dist)')dnl + sinusoid(squiggleampl,squigglefreq,-twopi_/4,0,m4dist,`$4') \ + with .Origin at last line.start + move to last line.end') +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,,,thick 2 dotted outlined "blue" ) + +.PE diff --git a/graphics/circuit_macros/examples/extras/Venus.m4 b/graphics/circuit_macros/examples/extras/Venus.m4 new file mode 100644 index 0000000000..676cd98143 --- /dev/null +++ b/graphics/circuit_macros/examples/extras/Venus.m4 @@ -0,0 +1,74 @@ +.PS +# venus.m4 +# https://tex.stackexchange.com/questions/576423/a-more-precise-dance-of-planets-with-metapost-and-tikz +# https://tex.stackexchange.com/questions/575986/dance-of-venus-and-variations-in-tikz-pgf + +gen_init +NeedDpicTools +maxpsht = 20 + +thinlines_ + +define(`venus', +`setkeys_(`$1', + outerlength:4; + innerlength:2.8933; + outerrate:8; + innerrate:13; + maxtimes:2880; + increment:2; + changephase:0 ) + sizefactor = 165/200 + nmaxtimes = 360*m4outerrate + for x=0 to nmaxtimes by m4increment do { + if "$2" != "" then { hue = \ + abs(sind(360*x/nmaxtimes*abs(m4innerrate-m4outerrate)+m4changephase-60)) + hsvtorgb(hue*360,1,1,r,g,b) + line from (Rect_(m4outerlength,x))*sizefactor \ + to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor \ + outlined rgbstring(r,g,b) } \ + else { + line from (Rect_(m4outerlength,x))*sizefactor \ + to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor + } + } ') + +AA:[ + sizefactor = 1/2.54 + define(`venusA',`[ + setkeys_(`$1', + iterations:270; + outerdistance:5.41; + innerdistance:7.48; + outerperiod:123; + innerperiod:200; + step:5) + for x=0 to m4iterations by m4step do { + line from (Rect_(m4outerdistance,x))*sizefactor \ + to (Rect_(m4innerdistance,x/m4outerperiod*m4innerperiod))*sizefactor \ + outlined "gray" + } + ]') + +# 3 columns, 5 rows + sizefactor /= 3 + Orig:(0,0) + for i=1 to 5 do { + iteri = 180 + (i-1)*540 + for j=1 to 3 do { + if (i==1) && (j==1) then { iter = 270 } \ + else { iter = iteri + (j-1)*180 } + V[i,j]: venusA(iterations=iter) with .sw at Orig + sprintf("%g",iter) at last [] #colored rgbstring(1,0,0) + Orig: V[i,j].se + } + Orig: V[i,1].sw-(0,V[i,1].ht) + } + ] + +BB:[ + venus(outerrate=8;innerrate=17;increment=2;innerlength=3.5;changephase=60,T) + ] at AA +# ] with .nw at AA.sw+(0,-0.5) + +.PE diff --git a/graphics/circuit_macros/examples/extras/birds.m4 b/graphics/circuit_macros/examples/extras/birds.m4 deleted file mode 100644 index 4b42ea35af..0000000000 --- a/graphics/circuit_macros/examples/extras/birds.m4 +++ /dev/null @@ -1,36 +0,0 @@ -.PS -# Birds.m4 -gen_init - -scale = 50 -linethick = 2*linethick - -define bird {[ - line shaded "$1" from (0,0) to \ - (10,-5) to (19,8) to (35,7) to (38,-12)+(0,2) to (60,0) to\ - (75,23) to (80,40) to (52,37)+(2,2) to (74,50) to (52,50) to \ - (60,60) to (38,48)+(0,2) to (35,67) to (19,68) to (10,55) to \ - (0,60) to (-8,50) to (14,50) to (-8,37)+(2,2) to (20,40) to \ - (15,23) to (0,0) -E: (80,40) -W: (20,40) -N: (19,68) -S: (19,8) - line outlined "gray" from (35,15) down 10 right 25 - line outlined "gray" from (40,20) right 25 down 8 - line outlined "gray" from (42,25) right 28 down 6 - line outlined "gray" from (40,30) right 32 down 4 - circle outlined "gray" rad 1 at (1,55) - circle outlined "gray" rad 4 at (24,55) -]} - - ncols = 4 - nrows = 4 - right - for i=0 to nrows-1 do { - for j=0 to ncols-1 do { move to (j*60,-i*60) - if (i+j)%2==0 then { bird(black) } else { bird(white) } - } - } - -.PE diff --git a/graphics/circuit_macros/examples/extras/bistable.m4 b/graphics/circuit_macros/examples/extras/bistable.m4 deleted file mode 100644 index ac49023863..0000000000 --- a/graphics/circuit_macros/examples/extras/bistable.m4 +++ /dev/null @@ -1,35 +0,0 @@ -.PS -# `bistable.m4' -cct_init # Default initialization - - up_ -rgbdraw(1,0,0, -Q1: bi_tr(,R) # Q1 upward with base to the right - llabel(,Q_1) ) # Label to left of last [] -rgbdraw(0,0,1, -Q2: bi_tr with .C at Q1.C+(elen_*7/4,0) # Q2 with base to left - rlabel(,Q_2) ) - - ground(at Q1.E) - ground(at Q2.E) - - line right_ dimen_/3 from Q1.B # Extend the base conductors -B1: Here - line left_ dimen_/3 from Q2.B -B2: Here - - resistor(up_ elen_*0.75 from Q1.C); llabel(,"$R_L$" wid 0.16) # Load resistors - line to (Q2.C,Here) "$V_{\hbox{cc}}$" below - resistor(down_ to Q2.C); llabel(,R_L) - - move to Q1.C+(0,dimen_/5) - { resistor(right_ to (B1,Here)); llabel(,R_1) -X: line to B2 } # Label the line to be jumped - resistor(from (Q2.C,Here) left_ to (B2,Here)); rlabel(,R_1) - crossover(to B1,R,X) - - resistor(down_ elen_*0.75); rlabel(,R_2) # Bias resistors - {"$-V_{\hbox{cc}}$" rjust} - line to (B2,Here) - resistor(up_ to B2); rlabel(,R_2) -.PE diff --git a/graphics/circuit_macros/examples/extras/brace.m4 b/graphics/circuit_macros/examples/extras/brace.m4 deleted file mode 100644 index b0089fe96d..0000000000 --- a/graphics/circuit_macros/examples/extras/brace.m4 +++ /dev/null @@ -1,115 +0,0 @@ -.PS -# brace.m4 -gen_init -NeedDpicTools - -divert(-1) - `bracket(linespec, end depth, - thickness, end thickness, attributes) - Square bracket along linespec - default depth is linewid/5 - attributes = eg - thick 0.4 outlined "string" shaded "string" - (default black)' -define(`bracket',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) - M4brS: last line.start; M4brE: last line.end - [ brdepth = ifelse(`$2',,linewid/5,`($2)') - brthick = ifelse(`$3',,brdepth/6,`($3)') - endthick = ifelse(`$4',,brthick/3,`($4)') - define(`m4brackattribs', - `ifelse(`$5',,`thick 0.4 shaded rgbstring(0,0,0)',`$5')')dnl - {line m4brackattribs \ - from M4brS+vec_(0,brdepth) to M4brS+vec_(0,brdepth+brthick) \ - then to M4brE+vec_(0,brdepth+brthick) \ - then to M4brE \ - then to M4brE+vec_(-endthick,0) \ - then to M4brE+vec_(-endthick,brdepth) \ - then to M4brS+vec_( endthick,brdepth) \ - then to M4brS+vec_( endthick,0) \ - then to M4brS \ - then to M4brS+vec_(0,brdepth) } - S: M4brS - ] with .S at Here') - - `brace(linespec,depth,arm thickness,attributes) - Curly brace along linespec - default depth is linewid/5 - attributes = eg - thick 0.4 outlined "string" shaded "string" - (default black)' -define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) - M4brS: last line.start; M4brE: last line.end - [ brdepth = ifelse(`$2',,linewid/5,`$2') - brthick = ifelse(`$3',,brdepth/6,`$3') - define(`m4braceattribs', - `ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl - tension = 0.55 - halfwid = distance(M4brS,M4brE) - smallrad = brdepth-brthick - bigrad = brdepth+brthick - for sgn=1 to -1 by -2 do { - S: rvec_(sgn*halfwid/2,0) - A: S+vec_(0,smallrad/2) - B: vec_(0,smallrad/2) - T: vec_(0,brdepth) - C: vec_(0,bigrad/2) - D: vec_(sgn*halfwid/2,bigrad/2) - {spline tension m4braceattribs \ - from S to tension between S and A \ - then to tension between A-vec_(sgn*bigrad/2,0) and A \ - then to A-vec_(sgn*bigrad/2,0) \ - then to B+vec_(sgn*bigrad/2,0) \ - then to tension between B+vec_(sgn*bigrad/2,0) and B \ - then to tension between T and B \ - then to T \ - then to tension between T and C \ - then to tension between C+vec_(sgn*bigrad/2,0) and C \ - then to C+vec_(sgn*bigrad/2,0) \ - then to D-vec_(sgn*bigrad/2,0) \ - then to tension between D-vec_(sgn*bigrad/2,0) and D \ - then to tension between S and D \ - then to S } - } - E: (0,0) -] with .E at 0.5 between M4brS and M4brE') -divert(0)dnl - - del = 0.2 - maxht = 2 - minht = 0.3 - n = 16 - hmax = 360 -R1: [ - for i=0 to n-1 do { - x = i/n - y = minht*(1-x)+maxht*x - hsvtorgb(x*hmax,1,1,r,g,b) - brace(from ( -i*del,-y/2) up y,,,thick 0.4 shaded rgbstring(r,g,b)) - brace(from ((i+1)*del, y/2) down y,,,thick 0.4 \ - outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) - } - ] -R2: [ - for i=0 to n-1 do { - x = i/n - y = minht*(1-x)+maxht*x - hsvtorgb(x*hmax,1,1,r,g,b) - brace(from ( -i*del,-y/2) up y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ - shaded rgbstring(r,g,b)) - brace(from ((i+1)*del, y/2) down y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ - outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) - } - ] with .n at R1.s+(0,-0.2) -R3: [ - for i=0 to n-1 do { - x = i/n - y = minht*(1-x)+maxht*x - hsvtorgb(x*hmax,1,1,r,g,b) - bracket(from ( -i*del,-y/2) up y, 5bp__+x*20bp__, 2bp__+x*13bp__,, - thick 0.4 shaded rgbstring(r,g,b)) - bracket(from ((i+1)*del, y/2) down y, 5bp__+x*20bp__, 2bp__+x*13bp__,, - thick 0.4 outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) - } - ] with .n at R2.s+(0,-0.2) - -.PE diff --git a/graphics/circuit_macros/examples/extras/chaos.m4 b/graphics/circuit_macros/examples/extras/chaos.m4 deleted file mode 100644 index 17ae070e58..0000000000 --- a/graphics/circuit_macros/examples/extras/chaos.m4 +++ /dev/null @@ -1,39 +0,0 @@ -.PS -# chaos.m4 -# Example simulation of chaos equations. -gen_init -scale = 10 -define(`FF',`dnl - `$4' = `$1'+dt*10*(-`$1'+`$2') - `$5' = `$2'+dt*(28*`$1'-`$2'-`$1'*`$3') - `$6' = `$3'+dt*(-8*`$3'/3+`$1'*`$2') ') -[ -x0 = 1 -y0 = 0 -z0 = 0 -dt = 0.005 -nN = 100 -for i = 1 to nN do { - for j = 1 to 8 do { - FF(x0,y0,z0,x1,y1,z1) - FF(x1,y1,z1,x2,y2,z2) - FF(x2,y2,z2,x3,y3,z3) - FF(x3,y3,z3,x4,y4,z4) - spline from x0,y0 to x1,y1 then to x2,y2 then to x3,y3 then to x4,y4 - x0 = x4; y0 = y4; z0 = z4 - } - } -arrow from (-15,0) to (15,0); "$x$" ljust -line up 1 from (10,0); "$ 10$" at last line.start below -line up 1 from (-10,0); "$-10$" at last line.start below -arrow from (0,-15) to (0,15); "$y$" above -line right 1 from (0,10); "$ 10$" at last line.start rjust -line right 1 from (0,-10); "$-10$" at last line.start rjust -"$ 0$" at (0,0) below rjust -] -`"\parbox{2.5in}{\begin{eqnarray*} - \dot{x}_1 & = & 10(-x_1+x_2)\\ - \dot{x}_2 & = & 28x_1-x_2-x_1x_3\\ - \dot{x}_3 & = & -8x_3/3+x_1x_2 - .\end{eqnarray*}}"' at last [].s below -.PE diff --git a/graphics/circuit_macros/examples/extras/ex17.m4 b/graphics/circuit_macros/examples/extras/ex17.m4 new file mode 100644 index 0000000000..a304d7359b --- /dev/null +++ b/graphics/circuit_macros/examples/extras/ex17.m4 @@ -0,0 +1,43 @@ +.PS +# ex17.m4 +cct_init + +[ +nrows = 4 +ncols = 9 +linewid = linewid*0.6 # everything smaller +define(`elen_',linewid) # shorter default length + + for j = 1 to nrows do { + { for i = 1 to ncols do { + Point_(-120) resistor + Point_( 0) inductor + Point_( 120) capacitor + if i < ncols then {Point_(0) diode} } + } + Point_(-120) move to rvec_(elen_,0) + { for i = 1 to ncols do { + Point_(-60) capacitor + Point_( 60) resistor } + } + Point_(-60) move to rvec_(elen_,0) + } + Point_(0) for i = 1 to ncols-1 do { inductor } +] + +[ # an exercise of the `parallel_' macro: + down_ # for labelling + Point_(-80) # skew current direction + + parallel_(Sep=1.75*dimen_; + parallel_( + `capacitor(,C); rlabel(,,C_2)', + `resistor; rlabel(,R_2)' ), + parallel_( + `resistor; rlabel(,R_1); move to rvec_(-dimen_/5,0) + inductor(,W); rlabel(,L_1)', + `reversed(`source',to rvec_(elen_,0),V,sourcerad_*2.5); rlabel(,v_s)' ) + ) + +] with .sw at last [].se+(elen_,0) +.PE diff --git a/graphics/circuit_macros/examples/extras/hsv.m4 b/graphics/circuit_macros/examples/extras/hsv.m4 deleted file mode 100644 index 662184dd7d..0000000000 --- a/graphics/circuit_macros/examples/extras/hsv.m4 +++ /dev/null @@ -1,26 +0,0 @@ -.PS -# hsv.m4 -gen_init -NeedDpicTools - -define grid { (($2)*boxwid,($1)*boxht) } -r = 0 -g = 0 -b = 1 -rgbtohsv(r,g,b,h,s,v) -nstep = 4 -{ for j=0 to nstep do { - sprintf("%g",j/nstep) at ((0.5+j)*boxwid,-boxht/2) below } } - { "S" at ((0.5+nstep/2)*boxwid, -boxht) } -{ for i=0 to nstep do { sprintf("%g",i/nstep) at (-boxht/3,(i)*boxht) } } - { "V" at (-boxht,(nstep/2)*boxht) \ - "or" \ - "L" } -right_ -for v = 0 to nstep do { - { for s = 0 to nstep do { hsvtorgb(h,s/nstep,v/nstep,r,g,b) - box shaded rgbstring(r,g,b) } } - move up_ boxht; right_ } - - -.PE diff --git a/graphics/circuit_macros/examples/extras/person.m4 b/graphics/circuit_macros/examples/extras/person.m4 deleted file mode 100644 index 4fdf09d387..0000000000 --- a/graphics/circuit_macros/examples/extras/person.m4 +++ /dev/null @@ -1,45 +0,0 @@ -.PS -# person.m4 -gen_init - -divert(-1) - `person( - hght=expr;wdth=expr;fill="colorname") - e.g. person(hght=1;fill="gray")' -define(`person', - `[ pushkeys_(`$1',hght:linewid;wdth:m4hght*2/5;fill:"black":N)dnl - bodywid = m4wdth/2 - bodyrad = bodywid/8 - bodyht = (m4hght - bodywid - bodywid/16 + bodyrad*2)/2 - tmplth = linethick; linethick = 0 - Head: circle diam bodywid colored m4fill - Body: box rad bodyrad ht bodyht wid bodywid colored m4fill \ - with .n at Head.s+(0,-Head.diam/16) - armwid = bodywid/3 - Armleft: box wid armwid rad armwid/2 ht Body.ht-bodyrad colored m4fill \ - with .w at Body.e + (armwid/2,0) - Armright: box same with .e at Body.w + (-armwid/2,0) - Legleft: box wid bodywid/2.5 rad armwid/2 ht Body.ht colored m4fill \ - with .n at (Body.w,Body.s)+(bodywid/5,bodyrad*2) - Legright: box same with .n at (Body.e,Body.s)+(-bodywid/5,bodyrad*2) - linethick_(tmplth) popdef(`m4hght',`m4wdth',`m4fill') ]') - -divert(0)dnl - - linewid = 3*linewid - movewid = 0.2 - - setrgb(0.54,0.81,0.94,babyblue) - person(fill="babyblue") - move - person(wdth=linewid*3/4;fill="babyblue") - move - person(wdth=linewid;fill="babyblue") - move - person - move - resetrgb - person(hght=1;fill="gray") - - line up linewid with .c at last [].e+(linewid/10,0) -.PE diff --git a/graphics/circuit_macros/examples/extras/rotellipse.m4 b/graphics/circuit_macros/examples/extras/rotellipse.m4 deleted file mode 100644 index a49ce308b3..0000000000 --- a/graphics/circuit_macros/examples/extras/rotellipse.m4 +++ /dev/null @@ -1,20 +0,0 @@ -.PS -# `rotellipse.m4' -gen_init - -[ - E: ellipse shaded "red" outlined "blue" - - A: rotellipse(1,1,outlined "red" shaded "blue") with .w at E.e - Point_(45) - B: rotellipse(,,dotted fill_(0.9)) - C: rotellipse(,,colored "red") with .s at last [].n - thinlines_ - showbox_(A) - showbox_(B) - showbox_(C) - thicklines_ - -] with .sw at 1,1 - -.PE diff --git a/graphics/circuit_macros/examples/extras/squiggle.m4 b/graphics/circuit_macros/examples/extras/squiggle.m4 deleted file mode 100644 index 671ae2addd..0000000000 --- a/graphics/circuit_macros/examples/extras/squiggle.m4 +++ /dev/null @@ -1,26 +0,0 @@ -.PS -# squiggle.m4 -gen_init - -divert(-1) -dnl Should this macro be in libgen.m4 or would that be just adding clutter? - - `squiggle(linespec, - amplitude,wavelength,attributes)' - `squiggly line (sinusoid), e.g. - squiggle(up_ 1 right_ 2,,,outlined "red")' -define(`squiggle',`rpoint_(ifelse(`$1',,linewid,`$1')) - m4dist = lin_leng(last line) - m4cycles = int(m4dist/(ifelse(`$3',,0.25*scale,`$3'))+0.5) - define(`squiggleampl',`ifelse(`$2',,0.04*scale,`$2')')dnl - define(`squigglefreq',`(twopi_*m4cycles/m4dist)')dnl - sinusoid(squiggleampl,squigglefreq,-twopi_/4,0,m4dist,`$4') \ - with .Origin at last line.start - move to last line.end') -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,,,thick 2 dotted outlined "blue" ) - -.PE diff --git a/graphics/circuit_macros/examples/extras/venus.m4 b/graphics/circuit_macros/examples/extras/venus.m4 deleted file mode 100644 index 676cd98143..0000000000 --- a/graphics/circuit_macros/examples/extras/venus.m4 +++ /dev/null @@ -1,74 +0,0 @@ -.PS -# venus.m4 -# https://tex.stackexchange.com/questions/576423/a-more-precise-dance-of-planets-with-metapost-and-tikz -# https://tex.stackexchange.com/questions/575986/dance-of-venus-and-variations-in-tikz-pgf - -gen_init -NeedDpicTools -maxpsht = 20 - -thinlines_ - -define(`venus', -`setkeys_(`$1', - outerlength:4; - innerlength:2.8933; - outerrate:8; - innerrate:13; - maxtimes:2880; - increment:2; - changephase:0 ) - sizefactor = 165/200 - nmaxtimes = 360*m4outerrate - for x=0 to nmaxtimes by m4increment do { - if "$2" != "" then { hue = \ - abs(sind(360*x/nmaxtimes*abs(m4innerrate-m4outerrate)+m4changephase-60)) - hsvtorgb(hue*360,1,1,r,g,b) - line from (Rect_(m4outerlength,x))*sizefactor \ - to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor \ - outlined rgbstring(r,g,b) } \ - else { - line from (Rect_(m4outerlength,x))*sizefactor \ - to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor - } - } ') - -AA:[ - sizefactor = 1/2.54 - define(`venusA',`[ - setkeys_(`$1', - iterations:270; - outerdistance:5.41; - innerdistance:7.48; - outerperiod:123; - innerperiod:200; - step:5) - for x=0 to m4iterations by m4step do { - line from (Rect_(m4outerdistance,x))*sizefactor \ - to (Rect_(m4innerdistance,x/m4outerperiod*m4innerperiod))*sizefactor \ - outlined "gray" - } - ]') - -# 3 columns, 5 rows - sizefactor /= 3 - Orig:(0,0) - for i=1 to 5 do { - iteri = 180 + (i-1)*540 - for j=1 to 3 do { - if (i==1) && (j==1) then { iter = 270 } \ - else { iter = iteri + (j-1)*180 } - V[i,j]: venusA(iterations=iter) with .sw at Orig - sprintf("%g",iter) at last [] #colored rgbstring(1,0,0) - Orig: V[i,j].se - } - Orig: V[i,1].sw-(0,V[i,1].ht) - } - ] - -BB:[ - venus(outerrate=8;innerrate=17;increment=2;innerlength=3.5;changephase=60,T) - ] at AA -# ] with .nw at AA.sw+(0,-0.5) - -.PE -- cgit v1.2.3