summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-07-29 03:01:04 +0000
committerNorbert Preining <norbert@preining.info>2022-07-29 03:01:04 +0000
commitda2dc471ec5bb2620f0ef5a4a700b236d1a8af06 (patch)
treed928b5b5abe4df9287ffda090d15e777c78bd783 /graphics
parent5937dac9360bdf40d1b0baf9d7384b109fb5b7a7 (diff)
CTAN sync 202207290301
Diffstat (limited to 'graphics')
-rw-r--r--graphics/circuit_macros/CHANGES6
-rw-r--r--graphics/circuit_macros/Copying2
-rw-r--r--graphics/circuit_macros/README24
-rw-r--r--graphics/circuit_macros/darrow.m42
-rw-r--r--graphics/circuit_macros/doc/Circuit_macros.pdfbin1020598 -> 1023203 bytes
-rw-r--r--graphics/circuit_macros/doc/DiodesMan.m46
-rw-r--r--graphics/circuit_macros/doc/Version.tex2
-rw-r--r--graphics/circuit_macros/doc/body.tex93
-rw-r--r--graphics/circuit_macros/doc/defines.tex32
-rw-r--r--graphics/circuit_macros/dpictools.pic47
-rw-r--r--graphics/circuit_macros/examples/Diodes.m46
-rw-r--r--graphics/circuit_macros/examples/ShadeSector.m414
-rw-r--r--graphics/circuit_macros/examples/Shaky.m4107
-rw-r--r--graphics/circuit_macros/examples/csc.m483
-rw-r--r--graphics/circuit_macros/examples/examples.pdfbin898616 -> 902995 bytes
-rw-r--r--graphics/circuit_macros/examples/files.tex6
-rw-r--r--graphics/circuit_macros/examples/ics.m416
-rw-r--r--graphics/circuit_macros/examples/mf/cct.mf2
-rw-r--r--graphics/circuit_macros/examples/sfg.m433
-rw-r--r--graphics/circuit_macros/examples/svg/DiodesSVG.m46
-rw-r--r--graphics/circuit_macros/examples/svg/GeometrySVG.m4183
-rw-r--r--graphics/circuit_macros/examples/svg/LoglogSVG.m412
-rw-r--r--graphics/circuit_macros/examples/svg/Makefile8
-rw-r--r--graphics/circuit_macros/examples/svg/PconnSVG.m47
-rw-r--r--graphics/circuit_macros/examples/svg/SmithchartSVG.m4222
-rw-r--r--graphics/circuit_macros/examples/svg/cscSVG.m4101
-rw-r--r--graphics/circuit_macros/examples/svg/ex15SVG.m42
-rw-r--r--graphics/circuit_macros/examples/svg/examplesSVG.htmx36
-rw-r--r--graphics/circuit_macros/examples/svg/icsSVG.m416
-rw-r--r--graphics/circuit_macros/examples/svg/keyboardSVG.m4269
-rw-r--r--graphics/circuit_macros/examples/svg/sfgSVG.m439
-rw-r--r--graphics/circuit_macros/examples/tubedefs.m46
-rw-r--r--graphics/circuit_macros/gpic.m42
-rw-r--r--graphics/circuit_macros/lib3D.m42
-rw-r--r--graphics/circuit_macros/libSLD.m493
-rw-r--r--graphics/circuit_macros/libcct.m425
-rw-r--r--graphics/circuit_macros/libgen.m499
-rw-r--r--graphics/circuit_macros/liblog.m42
-rw-r--r--graphics/circuit_macros/mfpic.m42
-rw-r--r--graphics/circuit_macros/mpost.m42
-rw-r--r--graphics/circuit_macros/pgf.m42
-rw-r--r--graphics/circuit_macros/postscript.m42
-rw-r--r--graphics/circuit_macros/psfrag.m42
-rw-r--r--graphics/circuit_macros/pstricks.m42
-rw-r--r--graphics/circuit_macros/svg.m432
-rw-r--r--graphics/circuit_macros/xfig.m42
46 files changed, 1169 insertions, 488 deletions
diff --git a/graphics/circuit_macros/CHANGES b/graphics/circuit_macros/CHANGES
index 80c44977e3..775d3f614d 100644
--- a/graphics/circuit_macros/CHANGES
+++ b/graphics/circuit_macros/CHANGES
@@ -1,5 +1,8 @@
CHANGES
+Version 9.9: Changes to libSLD macros, diode, sfg macros, rs_box,
+ r_text, svg_rot, examples. Changed SVG color macros for consistency with
+ other postprocessors.
Version 9.8: Changes to libSLD macros, with descriptions
added to the manual. Tweaked macros ArcAngle, opamp, inductor, cross,
crossover, diode, rs_box, r_text, Deltasymbol, arrester, dswitch,
@@ -40,8 +43,7 @@ Version 8.8: Tweaks for source macro. Change to svg.m4 for
embedding pic diagrams into Tikz pictures. Changed the name of the
manual from CMman.pdf to Circuit_macros.pdf. Option for dswitch.
Version 8.7: Fixes for more robust nested macros and SVG color. Options
-for
- the source macro.
+ for the source macro.
Version 8.6: Options for switch, lswitch. Simplified Quick Start section
of the manual. Added WARNING to m4 output for default configuration
file gpic.m4. Macro pconnex tweaked for tikz.
diff --git a/graphics/circuit_macros/Copying b/graphics/circuit_macros/Copying
index deabe0231f..6ff1081c39 100644
--- a/graphics/circuit_macros/Copying
+++ b/graphics/circuit_macros/Copying
@@ -1,4 +1,4 @@
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/README b/graphics/circuit_macros/README
index 326bb4730d..430bf5e99f 100644
--- a/graphics/circuit_macros/README
+++ b/graphics/circuit_macros/README
@@ -1,5 +1,5 @@
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -116,7 +116,7 @@ USAGE
from within the tex document source as described in the manual. For
near-immediate viewing of the basic process, three windows can be kept
open: one in which to edit the source, one to process the source and
- produce postscript or pdf, and Okular or GSview 5.0, which updates
+ produce postscript or pdf, and a viewer such as GSview 5.0, which updates
when clicked.
INSTALLATION AND TESTING: See the INSTALL file.
@@ -160,9 +160,7 @@ GPIC:
and documentation is available from http://ftp.gnu.org/gnu/groff/
but there are mirror sites as well. A more extensive manual is found
in the documentation that comes with GNU pic, which is typically
- installed as gpic. A pdf copy is included with the dpic distribution
- and a version can be found on the web at
- http://www.kohala.com/start/troff/gpic.raymond.ps
+ installed as gpic. A pdf copy is included with the dpic distribution.
The original AT&T pic manual can be found at
http://doc.cat-v.org/unix/v10/10thEdMan/pic.pdf
@@ -188,10 +186,11 @@ SVG output, Inkscape:
EXAMPLES
A set of examples is included in this distribution, showing electric
circuits, block diagrams, flow charts, signal-flow graphs, basic
- use of colour and fill, and other applications. Read the manual
- Circuit_macros.pdf and view the files examples.pdf in the
- examples directory or make and view the html file in the examples/svg
- directory. For the curious, There are additional source
+ use of colour and fill, and other applications. Some of the examples
+ test the boundaries of the domain of application of dpic with m4 macros.
+ Read the manual Circuit_macros.pdf and view the files examples.pdf
+ in the examples directory or make and view the html file in the
+ examples/svg directory. For the curious, There are additional source
files in the examples directory that are not shown in examples.pdf.
For the possibly unstable development version of these macros, try
http://ece.uwaterloo.ca/~aplevich/Circuit_macros/
@@ -243,11 +242,8 @@ INTEGRATION WITH OTHER TOOLS:
showing how to use Circuit_macros with his setup is at
https://www.youtube.com/watch?time_continue=53&v=pFRIBvUJHS4
- A KDE interface created by Matteo Agostinelli can be found
- at http://wwwu.uni-klu.ac.at/magostin/cirkuit.html. A git
- repository of a newer version by Andrew G. for Linux is at
- https://github.com/ag-ckt/cirkuit/tree/V0.5.0. There is uncertainty
- about installation possibilities because of evolving library dependencies.
+ A git repository of a KDE interface by Andrew G. for Linux is at
+ https://github.com/ag-ckt/cirkuit/tree/V0.5.0.
Another recent introduction is at
https://www.root.cz/clanky/publikovanie-elektrickych-schem-a-diagramov-pomocou-circuit-macros/
diff --git a/graphics/circuit_macros/darrow.m4 b/graphics/circuit_macros/darrow.m4
index 4e3f757afc..e1d6073106 100644
--- a/graphics/circuit_macros/darrow.m4
+++ b/graphics/circuit_macros/darrow.m4
@@ -1,7 +1,7 @@
divert(-1)
darrow.m4 Macros for double lines and arrows
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/doc/Circuit_macros.pdf b/graphics/circuit_macros/doc/Circuit_macros.pdf
index 9dd8ad8377..9c67589a6f 100644
--- a/graphics/circuit_macros/doc/Circuit_macros.pdf
+++ b/graphics/circuit_macros/doc/Circuit_macros.pdf
Binary files differ
diff --git a/graphics/circuit_macros/doc/DiodesMan.m4 b/graphics/circuit_macros/doc/DiodesMan.m4
index fb433235e1..33789fa5c7 100644
--- a/graphics/circuit_macros/doc/DiodesMan.m4
+++ b/graphics/circuit_macros/doc/DiodesMan.m4
@@ -1,5 +1,5 @@
.PS
-# Diodes.m4
+# DiodesMan.m4
cct_init
movewid = 2pt__
@@ -16,6 +16,8 @@ movewid = 2pt__
move down 0.2; right_
{diode(,B) ; move ; "`{\tt diode(,B)}'" ljust}
move down 0.2; right_
+ {diode(,b) ; move ; "`{\tt diode(,b)}'" ljust}
+ move down 0.2; right_
{diode(,G) ; move ; "`{\tt diode(,G)}'" ljust}
move down 0.2; right_
{diode(,D) ; move ; "`{\tt diode(,D)}'" ljust}
@@ -39,7 +41,7 @@ movewid = 2pt__
{diode(,MK) ; move ; "`{\tt diode(,MK)}'" ljust}
}
- move right_ 2.0
+ move down_ sourcerad_ right_ 2.0
{ {diode(,Z,RE) ; move ; "`{\tt diode(,Z,RE)}'" ljust}
move down 0.30; right_
{diode(,U) ; move ; "`{\tt diode(,U)}'" ljust}
diff --git a/graphics/circuit_macros/doc/Version.tex b/graphics/circuit_macros/doc/Version.tex
index 91db3d8a25..45c581b3af 100644
--- a/graphics/circuit_macros/doc/Version.tex
+++ b/graphics/circuit_macros/doc/Version.tex
@@ -1 +1 @@
-Version 9.8
+Version 9.9
diff --git a/graphics/circuit_macros/doc/body.tex b/graphics/circuit_macros/doc/body.tex
index c7c7b2bc6b..b984ec0435 100644
--- a/graphics/circuit_macros/doc/body.tex
+++ b/graphics/circuit_macros/doc/body.tex
@@ -956,7 +956,7 @@ Diodes are shown in \FR{Diodes}.
\begin{figure}[h!t]
\input DiodesMan
\caption{The macro {\tt
- diode(\linespec, B|CR|D|L|LE[R]|P[R]|S|T|U|V|v|w|Z|{\sl chars}, [R][E])}.
+ diode(\linespec, B|b|CR|D|L|LE[R]|P[R]|S|T|U|V|v|w|Z|{\sl chars}, [R][E])}.
Appending {\tt K} to the second argument draws an open arrowhead.}
\label{Diodes}
\end{figure}
@@ -984,14 +984,21 @@ Similarly, the macro
{\tt resized(}{\sl factor},`{\sl macro name}',{\sl macro arguments}{\tt )}
\par
\noindent
-can be used to resize the body of an element by temporarily multiplying
-the {\tt dimen\_} macro by {\sl factor}. More general resizing should be
-done by redefining {\tt dimen\_} as described in \SR{Circuitscaling:}.
-These two macros can be nested; the following scales the above example
-by 1.8, for example
+will resize the body of an element by temporarily multiplying
+the {\tt dimen\_} macro by {\sl factor} but
+\Mfour\ primitives can be employed instead as follows:
\par
-{\tt resized(1.8,`diode',right\_ 0.4);}
-{\tt resized(1.8,`reversed',`diode',right\_ 0.4)}
+{\tt pushdef(`dimen\_',dimen\_*({\sl factor})),%
+{\sl macro name}({\sl arguments}) popdef(`dimen\_')}
+\par
+\noindent
+More general resizing should be
+done by redefining {\tt dimen\_} globally as described in \SR{Circuitscaling:}.
+%These two macros can be nested; the following scales the above example
+%by 1.8, for example
+%\par
+%{\tt resized(1.8,`diode',right\_ 0.4);}
+%{\tt resized(1.8,`reversed',`diode',right\_ 0.4)}
Fuses are shown in \FR{Fuses}
and switches with numerous controls in \FR{Switches}.
@@ -1919,7 +1926,7 @@ using the macro
\par
\noindent
where the {\sl r, g, b} values are in the range 0 to 1
-(integers from 0 to 255 for \SVG) to specify the rgb color.
+to specify the rgb color.
This macro is a wrapper for the following, which may be more convenient
if many elements are to be given the same color:
@@ -2245,18 +2252,18 @@ which executes the given actions successively with
The {\tt examples.pdf} and {\tt examplesSVG.html}
documents include samplers of some of their uses.
- Writing macros for special elements is always an option but the SLD
- macros allow considerable scope for customization. Diagram-wide
- or block-scope changes are made by redefining
- environmental variables, particularly
+ The SLD macros allow considerable scope for
+ customization using key-value pairs to set internal parameters.
+ In addition, diagram-wide or block-scope changes are made as usual
+ by redefining environmental variables, particularly
{\tt linethick,} for example, and {\tt linewidth} for scaling.
Element body sizes are altered using, for example,
{\tt define(`dimen\_',dimen\_*1.2)} as for the normal circuit elements.
- To apply such a change to a single element, use
- {\tt pushdef(`dimen\_',{\sl expr})} {\sl element statements}
+ To apply such a change to a single element or a group of them,
+ use {\tt pushdef(`dimen\_',{\sl expr})} {\sl element statements}
{\tt popdef(`dimen\_').}
The SLD library also includes a number of redefinable default
-style parameters, which are currently:
+style parameters, which are currently as follows:
\begin{verbatim}
define(`sl_breakersize_',`dimen_*3/16') # breaker box size
define(`sl_breakersep_',`dimen_/2') # breaker separation from body
@@ -2270,14 +2277,15 @@ define(`sl_loadwid_',`dimen_*0.32') # load width
define(`sl_loadlen_',`dimen_*0.45') # load length
define(`sl_transcale_',1) # transformer body scale factor
define(`sl_busthick_',linethick*2) # sl_bus line thickness
-define(`sl_busindent_',`min(dimen_/5,rp_len/5)') # bus end extension
+define(`sl_busindent_',`min(dimen_/5,rp_len/5)') # busbar end indent
\end{verbatim}
- The macros also allow for extensive customization of individual
- elements using a key-value mechanism.
+%The macros also allow for extensive customization of individual
+%elements using a key-value mechanism.
The greatest control of appearance is obtained by drawing all
elements individually; however,
provision is made for automatically attaching circuit breakers
+ (which occur often)
and other symbols to elements.
\subsection{Two-terminal SLD elements\label{TwoTermSLD:}}
@@ -2320,6 +2328,13 @@ then, instead of a breaker,
an $n$-line slash symbol is drawn using the macro
{\tt sl\_slash(at {\sl position, keys,} [$n$:]R|L|U|D|{\sl degrees}).}
+The separation of the optional attached breaker or other stem elements from
+the body is controlled by the {\tt sl\_breakersep\_} global
+parameter. Adding {\tt sep={\sl expr}} to the body keys
+adjusts separations for an element; otherwise, adding
+this key to argument 3 or 4 adjusts the separation of
+the corresponding attached object.
+
Otherwise, one or more of the extensive {\tt sl\_ttbox} body
key-value pairs will insert a custom breaker as needed. These keys include:
{\tt lgth={\sl expr},
@@ -2380,7 +2395,9 @@ as necessary to customize and name the element head, of which the
default name is {\sl Head}.
The third argument controls the presence and type of the object in the stem
as for the two-terminal element breakers. The default breaker name is {\sl Br}
-and the default slash name is {\sl SL.}
+and the default slash name is {\sl SL,} and the separation from the head
+is specified using global {\tt sl\_breakersep\_} or the local
+{\tt sep={\sl expr}} parameters as for the two-terminal elements.
A stem of zero length is allowed when only the element head is needed.
Because a line segment of zero length has undefined direction, the
@@ -2448,7 +2465,18 @@ or the body-size parameter {\tt dimen\_.} For example, adding the line
\noindent%
after the {\tt cct\_init} line of {\tt quick.m4} produces slightly
-larger body sizes for all circuit elements. For logic elements, the
+larger body sizes for all circuit elements.
+
+For more localized resizing, use, for example,
+\par
+{\tt pushdef(`dimen\_',{\sl expression}) {\sl drawing commands}
+ popdef(`dimen\_')}
+\par
+\noindent
+(but ensure that the drawing commands have no net effect on the {\tt dimen\_}
+stack).
+
+For logic elements, the
equivalent to the {\tt dimen\_} macro is {\tt L\_unit}, which has
default value {\tt (linewid/10)}.
@@ -2570,6 +2598,7 @@ In the following,
two macros are defined to simplify the repeated drawing
of a series resistor and series inductor, and the macro {\tt tsection} defines
a subcircuit that is replicated several times to generate \FR{Tline}.
+\pagebreak
{\small \verbatiminput{Tline.m4}}
\begin{figure}[h!t]
% \ifpdf\vspace*{-\baselineskip}\fi%
@@ -3035,7 +3064,6 @@ the {\tt ifpstricks} macro in the second line of the diagram source) are
\hbox{}
-\pagebreak
Objects can be taylored to their attached text by invoking
\verb|\boxdims| and \verb|boxdim| explicitly.
The small source file in \FR{boxdims}, for example,
@@ -3121,17 +3149,24 @@ the rotation of text by \PSTricks postprocessing is illustrated by the file
which contains both horizontal text and text rotated $90^\circ$ along the
vertical line.
This rotation of text is also implemented by the macro
-{\tt rs\_boxs([angle={\sl expr};] {\sl text}[,{\sl expr, expr $\ldots$}])},
+{\tt rs\_boxs([angle={\sl degrees};] {\sl text}[,{\sl expr, expr $\ldots$}])},
which is similar
to {\tt s\_box} but rotates its argument by~$90^\circ,$ a default angle
that can be changed by preceding invocation with
\verb|define(`text_ang',|{\sl degrees}{\tt )}
-or by starting the first argument with {\tt angle={\sl expr};}.
+or by starting the first argument with {\tt angle={\sl degrees};}
+where {\sl degrees} is a decimal number (not an expression).
The {\tt rs\_box} macro
requires either \PSTricks or \TPGF and, like {\tt s\_box}, it calculates the
size of the resulting text box but requires the diagram to be
processed twice.
+The macro {\tt r\_text({\sl degrees, text,} at {\sl position})}
+works under \PSTricks, \TPGF, and \SVG, the last requiring
+processing twice. The {\sl degrees} argument is a decimal constant
+(not an expression) and the text is a simple string without quotes.
+The text box is not calculated.
+
Another common requirement is the filling of arbitrary shapes, as
illustrated by the following lines within a {\tt .m4} file:
@@ -3192,6 +3227,7 @@ The lines
\noindent\verb|\end{scope}%|
\vspace{\parsep}
+\pagebreak
This is accomplished, for example, by adapting the {\tt \bsl{}mtotex}
macro of \SR{Simplifications:} as follows:
@@ -3290,7 +3326,6 @@ as illustrated in \FR{Workflow} and in example files included with the
distribution. The \latex drawing commands alone or with {\tt eepic}
or {\tt pict2e} extensions are suitable only for simple diagrams.
-\pagebreak
\xection{Developer's notes\label{Developersnotes:}}
Years ago in the course of writing a book, I took a few days off to
write a \pic-like interpreter (\dpic) to eliminate the tedious coordinate
@@ -3321,7 +3356,7 @@ of lines. The learning curve of \pic\ compares well with other
possibilities, but some of the macros have become less readable as more
options and flexibility have been added, and if starting over today,
perhaps I would change some details. Compromises have been made in order
-to retain reasonable compatibility with the variety of postprocessors.
+to retain reasonable compatibility with the various postprocessors.
No choice of tool is without compromise, and producing good graphics
seems to be time consuming, no matter how it is done, but the payoff
can be worth the effort.
@@ -3370,10 +3405,13 @@ Many thanks to the people who continue to send comments, questions,
and, occasionally, bug fixes. What began as a tool for my own use changed
into a hobby that has persisted, thanks to your help and advice.
-\pagebreak
\xection{Bugs\label{Bugs:}}
This section provides hints and a list of common errors.
+First of all, be aware that old versions of \LaTeX, \dpic, and these
+macros are not always compatible. Updating an installation to current
+versions is often the way to eliminate mysterious error messages.
+
The distributed macros are not written for maximum robustness.
Macro arguments could be tested for correctness and
explanatory error messages could be written as necessary, but that
@@ -3391,7 +3429,6 @@ received.
\bflistitem}[2]{\phantomsection\pdfbookmark[subsection]{#1}{#2}{\bf #1: }}
\begin{enumerate}
-%\pagebreak
\item
\bflistitem{Misconfiguration}{misconfig}%
One of the configuration files
diff --git a/graphics/circuit_macros/doc/defines.tex b/graphics/circuit_macros/doc/defines.tex
index eb7d914fb2..dfcee2f91d 100644
--- a/graphics/circuit_macros/doc/defines.tex
+++ b/graphics/circuit_macros/doc/defines.tex
@@ -598,11 +598,12 @@
{macro for dimensioning diagrams;
{\sl arrowhead=}{\tt -> | <-}}
\macrodef{diode}{diode}{(\linespec,%
-B|CR|D|G|L|LE[R]|P[R]|S|Sh|T|U|V|v|w|Z|chars,%
+B|b|CR|D|G|L|LE[R]|P[R]|S|Sh|T|U|V|v|w|Z|chars,%
[R][E])}
{cct}
{diode:
{\tt B}=bi-directional,
+ {\tt b}=bi-directional with outlined zener crossbar,
{\tt CR}=current regulator,
{\tt D}=diac,
{\tt G}=Gunn,
@@ -1531,7 +1532,8 @@ elementspec}\char39,%
\macrodef{pushkeys\_}{pushkeys_}{({\sl string, key sequence})}
{gen}
{Multiple key-value definitions. Arg 2 is a semicolon-separated
- sequence of terms of the form {\tt {\sl key}:{\sl default value}:[N]}.
+ sequence of terms of the form {\tt {\sl key}:{\sl default value}:[N]}
+ which must contain no semicolons and the default values contain no colons.
Macro {\tt pushkey\_} is applied to each of the terms in order.
\seesect{Macroarguments:}}
\Letter{R}%
@@ -1603,14 +1605,13 @@ degrees})}
\macrodef{rgbdraw}{rgbdraw}{({\sl color triple}, {\sl drawing commands})}
{gen}
{color drawing for PSTricks, pgf, MetaPost, SVG postprocessors;
- (color entries are 0 to 1 except for SVG entries which are 0 to 255),
+ (color entries are 0 to 1),
see {\tt setrgb} \seesect{Semiconductors:}. Exceptionally, the color
of SVG arrows other than the default black has to be defined using the
{\tt outlined }{\sl string} and {\tt shaded }{\sl string} constructs.}
\macrodef{rgbfill}{rgbfill}{({\sl color triple}, {\sl closed path})}
{gen}
- {fill with arbitrary color (color entries are 0 to 1 except
- SVG entries which are 0 to 255); see {\tt
+ {fill with arbitrary color (color entries are 0 to 1); see {\tt
setrgb}\seesect{Semiconductors:}}
\macrodef{rgbstring}{rgbstring}{({\sl color triple or color name})}
{gen}
@@ -1629,9 +1630,12 @@ degrees})}
{Draw a right-angle symbol at {\sl Pos2}, of size
given by arg4. Arg5 =
line attributes, e.g., {\tt outlined "gray"}}
-\macrodef{r\_text}{s_text}{({\sl text},{\sl degrees})}
+\macrodef{r\_text}{r_text}{({\sl degrees},{\sl text},at {\sl position})}
{gen}
- {Rotate text by arg2 degrees (PSTricks, PGF, or SVG only).
+ {Rotate text by arg1 degrees (provides a single command for
+ PSTricks, PGF, or SVG only) placed at position in arg3.
+ The first argument is a decimal constant (not an expression) and
+ the text is a simple string without quotes.
\seesect{Interaction:}, \seesect{Pstricks:}}
\macrodef{rjust\_}{rjust_}{}
{gen}
@@ -1687,11 +1691,14 @@ degrees})}
\macrodef{rrot\_}{rrot_}{({\sl x, y, angle})}
{gen}
{\tt Here + vrot\_({\sl x, y, cos(angle), sin(angle))}}
-\macrodef{rs\_box}{rs_box}{([angle={\sl expr};]
+\macrodef{rs\_box}{rs_box}{([angle={\sl degrees};]
{\sl text},{\sl expr1},$\cdots$)}
{gen}
{like {\tt s\_box} but the text is rotated by {\tt text\_ang}
- (default 90) degrees. Two or more args are passed to {\tt sprintf()}.
+ (default 90) degrees, unless
+ the first argument begins with {\tt angle={\sl decimal number};},
+ in which case the number defines the rotation angle.
+ Two or more args are passed to {\tt sprintf()}.
If the first argument begins with {\tt angle={\sl expr};} then
the specified angle is used.
The examples {\tt define(`text\_ang',45); rs\_box(Hello World)} and
@@ -1800,8 +1807,7 @@ $\ldots$)}
name}])}
{gen}
{define colour for lines and text, optionally named (default
- {\tt lcspec});
- svg values are integers from 0 to 255\seesect{Semiconductors:}}
+ {\tt lcspec}); \seesect{Semiconductors:}}
\macrodef{setkey\_}{setkey_}{({\sl string, key, default,}[N])}
{gen}
{Key-value definition, like {\tt pushkey\_()} but the resulting
@@ -1976,6 +1982,7 @@ justification})}
{\tt scale={\sl expr} (default 1.0)};
{\tt grnd={\sl expr} attached ground at given angle
(type {\tt S} or {\tt N}))};
+ {\tt sep={\sl{}expr}};
{\tt stemlgth={\sl{}expr}};
{\tt wdth={\sl{}expr}};
{\tt direct=U|D|L|R|{\sl degrees}} (drawing direction).
@@ -1985,6 +1992,9 @@ justification})}
The {\tt L} (default) variant also defines internal labels
Internal labels {\sl L} and {\sl C} are included.
+ Key {\tt sep} is the type-{\tt S} separation from the head to the centre
+ of the slash symbol.
+
Key {\tt scale} allows scaling (default scale 1.0) but, with \dpic,
the {\tt scaled} directive can also be used.
\seesect{SingleLine:}}
diff --git a/graphics/circuit_macros/dpictools.pic b/graphics/circuit_macros/dpictools.pic
index fc3ec3f62c..66453a30e4 100644
--- a/graphics/circuit_macros/dpictools.pic
+++ b/graphics/circuit_macros/dpictools.pic
@@ -3,7 +3,7 @@
# m4 macro NeedDpicTools or the pic statement copy "HOMELIB_/dpictools.pic"
# when HOMELIB_ is defined or, generically, copy "<path>dpictools.pic"
-# Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under #
+# Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under #
# the LaTeX Project Public Licence in file Licence.txt. The files of #
# this distribution may be redistributed or modified provided that this #
# copyright notice is included and provided that modifications are clearly #
@@ -49,7 +49,6 @@ define testexpr { $1 = 0; [for i_testexpr=2 to $+ do {
# C-like loop. Commas in arg3 and arg4 must
# be in quotes or parentheses, e.g.,
# loop(i=1, i<=3, i+=1, print i) prints 1, 2, 3
-ld__ = 0
define loop {ld__+=1
$1
for lx__[ld__]=0 to 1 do {
@@ -167,8 +166,8 @@ define randn {
if "$3"=="" then { m_randn = 0 } else { m_randn = $3 }
if "$4"=="" then { s_randn = 1 } else { s_randn = $4 }
for i_randn=1 to n_randn by 2 do {
- loop( t_randn=2, t_randn >= 1, u_randn = 2*rand()-1; v_randn = 2*rand()-1
- t_randn = u_randn^2+v_randn^2 )
+ for done=0 to 1 do { u_randn=2*rand()-1; v_randn=2*rand()-1
+ t_randn = u_randn^2+v_randn^2; done=(t_randn<1) }
t_randn = sqrt( -2*loge(t_randn)/t_randn )
$1[i_randn] = u_randn*t_randn*s_randn+m_randn
if i_randn < n_randn then {
@@ -484,10 +483,14 @@ define lthick {(linethick bp__)}
if dpicopt==optSVG then { define px__ {*(scale/dpPPI)} } \
else { define px__ {*(scale/96)} } # Absolute pixels
-rtod_ = 57.295779513082323
-dtor_ = 0.017453292519943295
-twopi_ = 6.2831853071795862
-pi_ = twopi_/2
+define assign_dpicvars {
+ ld__ = 0
+ rtod_ = 57.295779513082323
+ dtor_ = 0.017453292519943295
+ twopi_ = 6.2831853071795862
+ pi_ = twopi_/2
+ $1
+ }
# Polar to rectangular conversion
define Rect_ {($1)*cos(($2)*dtor_),($1)*sin(($2)*dtor_)}
@@ -516,16 +519,16 @@ define dpshade { beginshade($1); $2; endshade } # like libgen shade()
# beginshade
if dpicopt==optPGF then {
define beginshade { if "$1"!="" then { dpshade_=$1 } else { dpshade_=0.5 }
- command "\global\let\dpicshdraw=\dpicdraw\global\def\dpicdraw{}"
- command "\global\def\dpicstop{--}"
- command sprintf("\dpicshdraw[fill=white!%g!black]",dpshade_*100) } } \
+ command "\global\let\dpicshdraw=\dpicdraw\global\def\dpicdraw{}"
+ command "\global\def\dpicstop{--}"
+ command sprintf("\dpicshdraw[fill=white!%g!black]",dpshade_*100) } } \
else { if dpicopt==optPSTricks then {
define beginshade { if "$1"!="" then { dpshade_=$1 } else { dpshade_=0.5 }
- command sprintf("\newgray{m4fillv}{%g}",dpshade_)
- command sprintf("\pscustom[fillstyle=solid,fillcolor=m4fillv]{%%") } } \
+ command sprintf("\newgray{m4fillv}{%g}",dpshade_)
+ command sprintf("\pscustom[fillstyle=solid,fillcolor=m4fillv]{%%") } } \
else { if dpicopt==optSVG then {
define beginshade { if "$1"!="" then { dpshade_=$1 } else { dpshade_=0.5 }
- command sprintf("<g fill=\"rgb(%g,%g,%g)\">",int(dpshade_*255+0.5),\
+ command sprintf("<g fill=\"rgb(%g,%g,%g)\">",int(dpshade_*255+0.5),\
int(dpshade_*255+0.5),int(dpshade_*255+0.5))} } }}
# endshade
@@ -550,6 +553,22 @@ else { if dpicopt==optSVG then {
#######################################################################
+assign_dpicvars()
# print " *** dpic: dpictools.pic processed"
define dpictools_ {1}
+ case(abs(dpicopt),
+ optMFpic := -abs(optMFpic),
+ optMpost := -abs(optMFpic),
+ optPDF := -abs(optPDF),
+ optPGF := -abs(optPGF),
+ optPict2e := -abs(optPict2e),
+ optPS := -abs(optPS),
+ optPSfrag := -abs(optPSfrag),
+ optPSTricks := -abs(optPSTricks),
+ optSVG := -abs(optSVG),
+ optTeX := -abs(optTeX),
+ opttTeX := -abs(opttTeX),
+ optxfig := -abs(optxfig) )
+ dpicopt := -abs(dpicopt)
+
# dpictools end
diff --git a/graphics/circuit_macros/examples/Diodes.m4 b/graphics/circuit_macros/examples/Diodes.m4
index d08a032253..bb34913822 100644
--- a/graphics/circuit_macros/examples/Diodes.m4
+++ b/graphics/circuit_macros/examples/Diodes.m4
@@ -16,6 +16,8 @@ movewid = 2pt__
move down 0.2; right_
{diode(,B) ; move ; "`{\tt diode(,B)}'" ljust}
move down 0.2; right_
+ {diode(,b) ; move ; "`{\tt diode(,b)}'" ljust}
+ move down 0.2; right_
{diode(,G) ; move ; "`{\tt diode(,G)}'" ljust}
move down 0.2; right_
{diode(,D) ; move ; "`{\tt diode(,D)}'" ljust}
@@ -39,13 +41,13 @@ movewid = 2pt__
{diode(,MK) ; move ; "`{\tt diode(,MK)}'" ljust}
}
- move right_ 2.0
+ move down_ sourcerad_ right_ 2.0
{ {diode(,Z,RE) ; move ; "`{\tt diode(,Z,RE)}'" ljust}
move down 0.30; right_
{diode(,U) ; move ; "`{\tt diode(,U)}'" ljust}
move down 0.25; right_
{diode(,T) ; move ; "`{\tt diode(,T)}'" ljust}
- move down 0.30; right_
+ move down 0.20; right_
{diode(,P) ; move ; "`{\tt diode(,P)}'" ljust}
move down 0.30; right_
{diode(,LE) ; move ; "`{\tt diode(,LE)}'" ljust}
diff --git a/graphics/circuit_macros/examples/ShadeSector.m4 b/graphics/circuit_macros/examples/ShadeSector.m4
new file mode 100644
index 0000000000..0632fdb14f
--- /dev/null
+++ b/graphics/circuit_macros/examples/ShadeSector.m4
@@ -0,0 +1,14 @@
+.PS
+# ShadedSector.m4
+# https://tex.stackexchange.com/questions/635327/multi-color-circular-gradient-in-tikz
+
+gen_init
+NeedDpicTools
+
+ rx = 4
+ n = int(rx/lthick)
+ for i=1 to n do { left_
+ hsvtorgb((1-i/n)*180,1,1,r,g,b)
+ arc rad i/n*rx with .c at (0,0) outlined rgbstring(r,g,b) }
+
+.PE
diff --git a/graphics/circuit_macros/examples/Shaky.m4 b/graphics/circuit_macros/examples/Shaky.m4
index 7eff994d91..81364cf515 100644
--- a/graphics/circuit_macros/examples/Shaky.m4
+++ b/graphics/circuit_macros/examples/Shaky.m4
@@ -5,7 +5,7 @@ NeedDpicTools
divert(-1)
`An attempt to draw shaky hand-drawn lines'
- `shakyline(linespec,type,shake=expr,[shakevals])
+ `shakyline(linespec,type,shake=val,[shakevals])
Draw a line with a tremor
arg3: shake parameter (default 1)
arg4=normal(0,1) perturbations used if given'
@@ -17,17 +17,18 @@ define(`shakyline',
End: L_end_
llen = distance(Start,End)
npts = round_(llen/linewid*4)
- 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) }}
+ pushkey_(`$3',shake,1)dnl
+ sval = m4shake*llen/npts/8
+ if "$4"=="" then { randn(d,npts-1,0,sval) }\
+ else { for i=1 to npts-1 do { d[i] = $4[i]*sval) }}
P[0]: Start
- for i=1 to npts-1 do { P[i]: i/npts between Start and End + (vec_(0,d[i])) }
+ 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] }
+ spline ifdpic(ifelse(`$2',,ctension_)) $2 from P[0] to P[1]
+ for i=2 to npts do { continue to P[i] } popdef(`m4shake')
] with .Start at L_start_; move to L_end_')
- `shakyarc(arcspec,type,s=shake,[shakevals])
+ `shakyarc(arcspec,type,shake=val,[shakevals])
Draw an arc with a tremor
arg3: s=shake parameter (default 1)
arg4=normal(0,1) perturbations used if given'
@@ -44,99 +45,71 @@ define(`shakyarc',
ar = distance(Start,C)
llen = abs(ar*(ae-as))
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) }}
+ pushkey_($3,shake,1)dnl
+ sval = m4shake*llen/npts/8
+ if "$4"=="" then { randn(d,npts-1,0,sval) }\
+ else { for i=1 to npts-1 do { d[i] = $4[i]*sval }}
P[0]: Start
for i=1 to npts-1 do { P[i]: C + (rect_(ar+d[i],as+i/npts*(ae-as))) }
P[npts]: End
- spline $2 from P[0] to P[1]
- for i=2 to npts do { continue to P[i] }
+ spline ifdpic(ifelse(`$2',,ctension_)) $2 from P[0] to P[1]
+ for i=2 to npts do { continue to P[i] } popdef(`m4shake')
] with .Start at last arc.start; move to last arc.end')
- `shakyspline(points,type,s=shake,[shakevals])
- Draw a spline with a tremor
- arg3: s=shake parameter (default 1)
- arg4=normal(0,1) perturbations used if given'
-define(`shakyspline',
-`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1'))
- 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)
- 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) }}
- 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')
-
`shakyfitcurve(V,n,linetype,
- m (default 0),s=val,[shakevals])
+ m (default 0),shake=val,[shakevals])
Like fitcurve but the control points
are perturbed
arg5: s=shake parameter (default 1)
arg6=normal(0,1) perturbations used if given'
define(`shakyfitcurve',`
- {[ m4fn = `$2'; m4fm = ifelse(`$4',,0,`$4')
- M4P_[0]: `$1'[m4fm]
- setkey_($5,s,1)
-# if "$6"=="" then { !!!!
-# else { for i=1 to npts-1 do { d[i] = $5[i]*m4s*(llen/npts/8) }}
- for i=m4fm+1 to m4fn-1 do { M4P_[i-m4fm]: `$1'[i]*(4/3) }
- M4P_[m4fn-m4fm]: `$1'[m4fn]
- n = m4fn-m4fm
- # forward substitution
- M4P_[1]: M4P_[1]-M4P_[0]/6
- d[1] = 1
- for i = 2 to n-1 do {
- M4P_[i]: M4P_[i]-M4P_[i-1]/(d[i-1]*6)
- d[i] = 1-1/d[i-1]/36 }
- # backward substitution
- for i= n-1 to 1 by -1 do {
- M4P_[i]: (M4P_[i]-M4P_[i+1]/6)/d[i] }
- # draw using computed control points
- spline 0.55 `$3' from M4P_[0] to 11/32 between M4P_[0] and M4P_[1] \
- then to 5/32 between M4P_[1] and M4P_[2]
- for i=2 to n-2 do { continue to M4P_[i] }
- continue to 27/32 between M4P_[n-2] and M4P_[n-1] \
- then to 21/32 between M4P_[n-1] and M4P_[n] then to M4P_[n]
- ] with .M4P_[0] at `$1'[ifelse(`$4',,0,`$4')]} ')
+ [ m4fn = ifelse(`$2',,2,`$2'); m4fm = ifelse(`$4',,0,`$4')
+ pushkey_($5,shake,1)dnl
+ if "$6"=="" then { randn(d,2*(m4fn-m4fm-1),0,m4shake) }\
+ else { for i=1 to 2*(m4fn-m4fm-1) do { d[i] = $6[i]*m4shake }}
+ M4PP_[0]: `$1'[m4fm]
+ for i=m4fm+1 to m4fn-1 do { M4PP_[i-m4fm]: `$1'[i] dnl
+ +(d[2*(i-m4fm-1)+1],d[2*(i-m4fm-1)+2])\
+ *distance(M4PP_[i-m4fm-1],`$1'[i])/16 }
+ M4PP_[m4fn-m4fm]: `$1'[m4fn]; End: M4PP_[m4fn-m4fm]
+ fitcurve(M4PP_,m4fn-m4fm) popdef(`m4shake')
+ ] with .M4PP_[0] at `$1'[ifelse(`$4',,0,`$4')]; move to last [].End ')
divert(0)
-[
+P1: [
linethick = 2.5
round(,,colored "gray")
nl = 10
for i=0 to nl do {
- shakyline(right 6/nl up 2*(2*pmod(i,2)-1),colored "gray",shake=2-i/nl*2)
+ shakyline(right 6/nl up 2*(2*pmod(i,2)-1),,shake=2)
{sprintf("%g",2-i/nl*2) at 1/2 between L_start_ and L_end_ }
round(,,colored "gray") }
]
-[
+P2: [
linethick = 2.5
na = 3
arcrad = 1
for i=1 to na do {
- shakyarc(,colored "gray",s=1)
+ shakyarc(,colored "gray",shake=2)
}
] with .nw at last [].sw +(0,-1)
-[
+P3: [
linethick = 2.5
na = 3
arcrad = 2
for i=1 to na do {
- shakyarc(,colored "gray",s=1)
+ shakyarc(,colored "gray",shake=2)
}
- ] with .sw at last [].se +(1,0)
+ ] with .w at last [].e +(1,0)
+P4: [
+ n = 0
+ for a=0 to 359 by 30 do { V[n]: (Rect_(1,a)); n+=1 }
+ V[n]: V[0]
+ shakyfitcurve(V,n,,,shake=1)
+ ] with .nw at P2.sw + (0,-0.5)
.PE
diff --git a/graphics/circuit_macros/examples/csc.m4 b/graphics/circuit_macros/examples/csc.m4
index 69b8d20c3c..fdf4b4404f 100644
--- a/graphics/circuit_macros/examples/csc.m4
+++ b/graphics/circuit_macros/examples/csc.m4
@@ -1,12 +1,11 @@
.PS
#.PS 3.5
# csc.m4
+# This file includes AntiqueClock and works for PSTricks, Tikz, and SVG
gen_init
NeedDpicTools
-ifelse(ifpstricks(T)`'ifmpost(T)`'ifpostscript(T)`'ifpgf(T),,
- `PSTricks, MetaPost, PGF, or Postscript required for this diagram',`
-skale = 3.5/3.97*0.9955
+skale = 0.878
circlerad=1.91*skale
hubrad=0.10*skale
s=0.5*skale
@@ -49,7 +48,6 @@ rgbdraw(midnight,
# Sail
thinlines_
- setrgb(midnight)
rgbfill(midnight,
line from coord(0.44,3.38) to coord(0.44,2.6) \
then to coord(2.1,-1.75) \
@@ -76,16 +74,18 @@ rgbdraw(midnight,
spline to coord(-1,-2.08) then to coord(0.55,-1.77)
)
]
-')
-# PSTricks or tikz only:
-ifelse(ifpstricks(T)`'ifpgf(T),T,`
+
Clock: [
+# PSTricks, tikz, or svg only:
+ifelse(ifpstricks(T)`'ifpgf(T)`'ifsvg(T),T,`
#.PS
# AntiqueClock.m4
#gen_init
#NeedDpicTools
iflatex(`latexcommand({\sf)')
+ifsvg(svg_font(font-family="sans-serif" font-stretch="condensed")
+ svg_rot_init(test))
# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals
@@ -127,17 +127,27 @@ define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2
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) }
+ C1: rvec_(1.25*hhsf,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))
- ]')
+ tang = atan2((r1+q),d)
+ for i=0 to 3 do {
+ X[i]: C1+vec_(rect_(v, pi_+i/3*( tang-pi_)))
+ Y[i]: C1+vec_(rect_(v,-pi_+i/3*(-tang+pi_)))
+ }
+ n = 3
+ for i=1 to 4 do { aa = -pi_+tang + i/4*(pi_/2-tang)
+ XX: (d,r1+q)+(rect_(r1,aa))
+ n+=1;
+ X[n]: C1+vec_(XX.x, XX.y)
+ Y[n]: C1+vec_(XX.x,-XX.y)
+ }
+ m = n
+ for i= 0 to m do { n+=1; X[n]: Y[m-i] }
+ fitcurve(X,n,shaded rgbstring(0,0,0))
+ ]')
+
define(`AntiqueClock',`[ # h,m,s,diam
# Clock size parameters:
@@ -183,27 +193,34 @@ Face: circle thick 0 fill_(1) rad r3 at C
circle rad r6 at C
circle rad r7 at C
-# Text rotation for PSTricks or TikZ
- define(`rottext',
- `ifpstricks(`\rput[c]{%g}(0,0)',`ifpgf(`\pgftext[rotate=%g]',%g)')')
+# Ad hoc shift of rotated SVG text
+ ifsvg(`define adj {+(-cosd($`'1)*textht*0.5*sign(180-($`'1)),\
+ (0.25+0.25*cosd(2*($`'1)))*textht) }',
+ `define adj {}')
+
# Outer numbers
- command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4)
- for mn = -15 to 15 by 5 do { sprintf("rottext{\outerfont %g}",\
- -mn/60*360,pmod(mn,60)) at C+(Rect_((r3+r4)/2,90-mn/60*360)) }
- for mn = 20 to 40 by 5 do { sprintf("rottext{\outerfont %g}",\
- 180-mn/60*360,mn) at C+(Rect_((r3+r4)/2,90-mn/60*360)) }
+ iflatex(`command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4)')
+ ifsvg(`textht = (r3-r4)*0.6')
+ for_(-15,15,5,`aa=90-(m4x)*6
+ r_text(eval(-(m4x)*6),eval((m4x+60)%60),
+ at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
+ for_(20,40,5,`aa=450-(m4x)*6
+ r_text(eval(180-m4x*6),m4x,at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
# 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("rottext{\scalebox{0.7}[1.0]{\innerfont 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("rottext{\scalebox{0.7}[1.0]{\innerfont mx}}",-t+180) \
- at C+(Rect_((r5+r6)/2,90-t))', IV,V,VI,VII,VIII)
+ iflatex(`command sprintf("\font\innerfont=cmss12 at %4.2fin",r5-r6)')
+ ifsvg(`textht = (r5-r6)*0.6')
+ Loopover_(`mx',`aa=180-(m4Lx-1)*30
+ r_text(eval(120-m4Lx*30),iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
+ IX,X,XI,XII,I,II,III)
+ Loopover_(`mx',`aa=360-m4Lx*30
+ r_text(eval(90-m4Lx*30), iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
+ IV,V,VI,VII,VIII)
# Inner tics
for mn = 5 to 60 by 5 do { t = 90-mn/60*360
@@ -216,15 +233,15 @@ Face: circle thick 0 fill_(1) rad r3 at C
# Center
dot(at C,0.1/4*r1,1)
- ]')
+ ]') `# AntiqueClock'
Clock1: AntiqueClock(,,,3.5)
# Clock2: AntiqueClock(4,50,07,2) at Clock1.e+(1.5,0)
iflatex(`latexcommand(}%)')
-
+ ifsvg(`command "</g>"')
#.PE
+',` "AntiqueClock.m4 requires PSTricks, Tikz-pgf, or SVG" ')
] with .sw at last [].se+(0.25,0)
-',` "AntiqueClock.m4 requires pstricks or pgf" ')
.PE
diff --git a/graphics/circuit_macros/examples/examples.pdf b/graphics/circuit_macros/examples/examples.pdf
index 7b89aac55c..dafab3e6a7 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/files.tex b/graphics/circuit_macros/examples/files.tex
index 03c9ffa090..5fbcf50af8 100644
--- a/graphics/circuit_macros/examples/files.tex
+++ b/graphics/circuit_macros/examples/files.tex
@@ -99,7 +99,7 @@
\bfig{
{\small\centerline{\getpic{Xform}} }
- \caption{The transformer element, drawing direction down
+ \caption{Some variations of the transformer element, drawing direction down
\src{Xform.m4}.}
}
@@ -129,7 +129,7 @@
\bfig{
\centerline{\getpic{Relay}}
- \caption{Some variants of the {\tt relay} macro
+ \caption{Some variants of {\tt relay}
\src{Relay.m4}.}
}
@@ -667,7 +667,7 @@
\bfig{
\centerline{\getpic{Escher}}
- \caption{Two Escher-like objects
+ \caption{Penrose stairs and an Escher-like object
\src{Escher.m4}.}
}
diff --git a/graphics/circuit_macros/examples/ics.m4 b/graphics/circuit_macros/examples/ics.m4
index 98789b73cd..42286d5a8f 100644
--- a/graphics/circuit_macros/examples/ics.m4
+++ b/graphics/circuit_macros/examples/ics.m4
@@ -243,17 +243,17 @@ define(`HDMI_micro',`[
D0`$+$', D0\_SH, D0`$-$', CLK`$+$', CLK\_SH, CLK`$-$',
CEC, GND, SCL, SDA,$+${5}V)
line from Base.nw+(m4bwid*2/3-lg_pinsep,0) up plen
- r_text(21) at last line.c+(-5bp__,0)
- r_text(SH2) at last line.start + (0,-10bp__)
+ r_text(,21,at last line.c+(-5bp__,0))
+ r_text(,SH2,at last line.start + (0,-10bp__))
line from Base.nw+(m4bwid*2/3-2*lg_pinsep,0) up plen
- r_text(20) at last line.c+(-5bp__,0)
- r_text(SH1) at last line.start + (0,-10bp__)
+ r_text(,20,at last line.c+(-5bp__,0))
+ r_text(,SH1,at last line.start + (0,-10bp__))
line from Base.sw+(m4bwid*2/3-lg_pinsep,0) down plen
- r_text(23) at last line.c+(-5bp__,0)
- r_text(SH4) at last line.start + (0, 10bp__)
+ r_text(,23,at last line.c+(-5bp__,0))
+ r_text(,SH4,at last line.start + (0, 10bp__))
line from Base.sw+(m4bwid*2/3-2*lg_pinsep,0) down plen
- r_text(22) at last line.c+(-5bp__,0)
- r_text(SH3) at last line.start + (0, 10bp__)
+ r_text(,22,at last line.c+(-5bp__,0))
+ r_text(,SH3,at last line.start + (0, 10bp__))
#
`$4']')
diff --git a/graphics/circuit_macros/examples/mf/cct.mf b/graphics/circuit_macros/examples/mf/cct.mf
index 85a84e5a7f..10b713bb50 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 2022/02/11 at 17:20
+% from TeX source "font" on 2022/07/27 at 16:40
numeric mfpicversion; mfpicversion := 110;
if unknown mode: mode := localfont; fi
if unknown mag: mag := 1000/1000; fi
diff --git a/graphics/circuit_macros/examples/sfg.m4 b/graphics/circuit_macros/examples/sfg.m4
index 9a97d828d5..a2efdb2ec6 100644
--- a/graphics/circuit_macros/examples/sfg.m4
+++ b/graphics/circuit_macros/examples/sfg.m4
@@ -14,7 +14,7 @@ T:[
sfgline(,K/M)
DDY2: sfgnode(,\ddot{y}_2,sfgbelow rjust)
sfgline(,s^{-1})
- DY2: sfgnode(,`\dot{y}_2=x_2',sfgbelow ljust)
+ DY2: sfgnode(,\d`'ot{y}_2=x_2,sfgbelow ljust) dnl dot is an m4 macro
sfgline(,s^{-1})
Y2: sfgnode(,y_2=x_1,sfgbelow ljust)
@@ -23,6 +23,7 @@ T:[
sfgarc(from Y2 to DDY2,-K/M,above,ccw,sf)
sfgarc(from Y2 to Y1,1,sfgabove,,sf)
]
+#showbox_(,"T")
# Graph 2
B: [
@@ -39,6 +40,7 @@ B: [
sfgself(at X1,R,\;a_{11},ljust,cw,1.5)
sfgself(at X2,-90,a_{22},sfgbelow)
] with .w at T.e + (linewid/2,-linewid/4)
+#showbox_(,"B")
# Graph 3
G3: [#sfg_init( 0.85,0.35/2 ) # change node spacing and increase node size
@@ -50,6 +52,7 @@ G3: [#sfg_init( 0.85,0.35/2 ) # change node spacing and increase node size
sfgarc(from N2 to N1,F_2,sfgabove,ccw,)
sfgarc(from N3 to N1,F_3,sfgbelow,ccw,1.4)
] with .nw at T.sw
+#showbox_(,"G3")
A: [#sfg_init( 0.75,0.15 )
sfg_wid = 0.75
@@ -65,6 +68,7 @@ A: [#sfg_init( 0.75,0.15 )
sfgself(at R,-90,e,sfgabove,cw)
arrow right linewid*2/3 from R.e
] with .w at G3.e+(linewid/2,0)
+#showbox_(,"A")
G4: [sfg_init( 2.0,0.25/2 ) # change node spacing and increase node size
s1 = 0.9
@@ -85,6 +89,33 @@ G4: [sfg_init( 2.0,0.25/2 ) # change node spacing and increase node size
sfgline(right_ sfg_wid/2,\nu+3\lambda,below,->)
{"$\ldots$" wid 0.3 ljust}
] with .nw at G3.sw+(0,-0.15)
+#showbox_(,"G4")
+
+# https://tex.stackexchange.com/questions/637455/tikz-how-to-set-exact-position-of-node
+G5: [sfg_init( 1.75,0.25/2 ) # change node spacing and increase node size
+ Dstar: sfgnode(,*)
+ D0: sfgnode(at Dstar+(2,0),\diamond_0)
+ sfgline(,`1-r_{x{-}1,x}-q^i_{x{-}1,x}',,->)
+ Ddots: sfgnode(,\cdots)
+ sfgline(,`1-r_{x{-}4,x}-q^i_{x{-}4,x}',,->)
+ D5: sfgnode(,\diamond_5)
+ DD: sfgnode(at D0+(0,-1.0),\dagger)
+ sfgself(at Dstar,L,,,,0.5)
+ "$`1-i_x-q^a_x'$" wid 45bp__ at Dstar + (-0.3,0.25)
+ sfgself(at DD,D,1\mathstrut,above_,,0.5)
+ sfgself(at D5,R,,,,0.5)
+ "$`1-q^i_x-r_x'$" wid 47bp__ at D5 + (0.3,0.25)
+ sfgarc(from D0 to Dstar ->,`r_{x,x}\mathstrut',below_,ccw)
+ sfgarc(from Dstar to D0 ->,`i_x\mathstrut',above_,ccw)
+ sfgarc(from Dstar to DD ->,`q^a_x\mathstrut',above_ ljust_,ccw)
+ sfgline(from D0 to DD,`\;q^i_{x,x}',ljust,->)
+ sfgarc(from Ddots to Dstar,`r_{j,x}\mathstrut',below_,ccw,,->)
+ sfgarc(from Ddots to DD ->,`q^i_{x{-}j,x}\mathstrut',above_ rjust_,)
+ sfgarc(from D5 to Dstar ->,`r_x\mathstrut',below_,ccw)
+ sfgarc(from D5 to DD ->,`q^i_x\mathstrut',above_ rjust_,)
+ ] with .nw at G4.sw+(0,-0.15)
+#howbox_(,"G5")
+
move from (T.w,G4.s)-(7bp__,6bp__) to B.ne+(15bp__,6bp__)
]
#showbox_
diff --git a/graphics/circuit_macros/examples/svg/DiodesSVG.m4 b/graphics/circuit_macros/examples/svg/DiodesSVG.m4
index 543132fe33..8af6a2e298 100644
--- a/graphics/circuit_macros/examples/svg/DiodesSVG.m4
+++ b/graphics/circuit_macros/examples/svg/DiodesSVG.m4
@@ -15,6 +15,8 @@ movewid = 2pt__
move down 0.2; right_
{diode(,B) ; move ; "`diode(,B)'" ljust}
move down 0.2; right_
+ {diode(,b) ; move ; "`diode(,b)'" ljust}
+ move down 0.2; right_
{diode(,G) ; move ; "`diode(,G)'" ljust}
move down 0.2; right_
{diode(,D) ; move ; "`diode(,D)'" ljust}
@@ -38,8 +40,8 @@ movewid = 2pt__
{diode(,MK) ; move ; "`diode(,MK)'" ljust}
}
- move right_ 2.0
-{ {diode(,Z,RE) ; move ; "`diode(,Z,RE)'" ljust}
+ move down_ sourcerad_ right_ 2.0
+{ {diode(,Z,RE) ; move ; "`diode(,Z,RE)'" wid 70bp__ ljust}
move down 0.25; right_
{diode(,T) ; move ; "`diode(,T)'" ljust}
move down 0.30; right_
diff --git a/graphics/circuit_macros/examples/svg/GeometrySVG.m4 b/graphics/circuit_macros/examples/svg/GeometrySVG.m4
index de5fc62523..576315d285 100644
--- a/graphics/circuit_macros/examples/svg/GeometrySVG.m4
+++ b/graphics/circuit_macros/examples/svg/GeometrySVG.m4
@@ -2,98 +2,9 @@
# Geometry.m4
# Some constructions from https://tex.stackexchange.com/
gen_init
+maxpswid = 9
-Fig1: [ ls = 2/3 # local scale
- A: Here; "A" at A above
- B: A+(-1*ls,-3.5*ls); "B" at B below rjust
- C: B+(4.6*ls,0); "C" at C below ljust
- AB: line from A to B
- BC: line from B to C
- CA: line from C to A
-
- 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)
- S: move from A to (sin(angleLAC/2),-cos(angleLAC/2))
- AW: line from A to Intersect_(S,BC)
- W: Here; "W" at W below 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
- CM: line from B to M; RightAngle(B,M,C)
-
- H: Intersect_(CN,AL); "H" at H +(4bp__,10bp__)
-
- thinlines_
- Equidist3(B,L,N,CC1,c1rad); C1: circle rad c1rad at CC1
- Equidist3(B,W,N,CC2,c2rad); C2: circle rad c2rad at CC2
- Equidist3(B,C,N,CC3,c3rad); C3: circle rad c3rad at CC3
- Equidist3(W,C,M,CC4,c4rad); C4: circle rad c4rad at CC4
- thicklines_
-
- Z: LCintersect(AW,CC2,C2.rad); "Z" at Z+(-5bp__,-5bp__)
- HZ: move from H to Z
- Y: LCintersect(HZ,CC4,C4.rad,R); "Y" at Y above
- X: LCintersect(HZ,CC2,C2.rad); "X" at X above rjust
-
- Loopover_(`P',`dot(at P)',X,Y,Z)
-
- line dashed from X to Y chop -linewid/2
- RightAngle(A,Z,Y)
- ]
-
-Fig2: [ ls = 3/4 # local scale
-# https://tex.stackexchange.com/questions/593272/drawing-complex-geometry
- P: dot(at Here); "P" at P.s below
- N: dot(at P+(3.5*ls,1.5*ls)); "N" at N.se ljust below
- O: dot(at (N,P)); "O" at O.s below
- R: dot(at 1/3 between O and P);"R" at R.s below
- M: dot(at (R,N)); "M" at M.se ljust below
- Q: dot(at (M.x,M.y+distance(M,N)/distance(N,O)*distance(P,O)));"Q" at Q.e ljust
- line from P to Q then to N then to O
- B: line to P chop -0.3
- line from M to N
- Pu: line from R to Q chop 0 chop -0.3
- H: line from P to N chop 0 chop -0.3
- X: dot(at Intersect_(Pu,H)); "X" at X.se ljust below
- thinlines_
- RightAngle(Q,M,N)
- RightAngle(Q,N,H.end)
- RightAngle(N,O,B.start)
- ArcAngle(N,P,Q,0.4); "svg_beta" at last arc.ne above ljust
- ArcAngle(O,P,N,0.5); "svg_alpha" at last arc.start+(5bp__,8bp__)
- ArcAngle(R,Q,N,0.5); "svg_alpha" at last arc.start+(8bp__,-5bp__)
- ] with .w at Fig1.e+(-0.4,0)
-
-Fig3: [
-# FourbarSVG.m4
-# https://tex.stackexchange.com/questions/609452/help-drawing-a-more-sophisticated-right-triangle-with-tikz-or-something-else
-
- textkht = 12/72
- unit = 0.6
- 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 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,,"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 .nw at Fig1.sw+(0.2,-0.3)
-
-Fig4: [
-
+Fig1: [
# FourbarSVG.m4
# https://tex.stackexchange.com/questions/563831/how-to-draw-four-bar-linkage-with-center-of-mass
ls = 1/25.4 # local scale
@@ -149,7 +60,95 @@ define(`pivot',`[
line from A0+(3*ls,0) right 8*ls
ArcAngle(Here,A0,B1,9*ls) ->; "svg_theta`'svg_sub(0)" \
at last arc.start+(2,2)*ls
+ ]
+
+Fig2: [
+# FourbarSVG.m4
+# https://tex.stackexchange.com/questions/609452/help-drawing-a-more-sophisticated-right-triangle-with-tikz-or-something-else
+
+ textkht = 12/72
+ unit = 0.6
+ 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 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,,"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 .nw at Fig1.sw+(0.2,0)
+
+
+Fig3: [ ls = 3/4 # local scale
+# https://tex.stackexchange.com/questions/593272/drawing-complex-geometry
+ P: dot(at Here); "P" at P.s below
+ N: dot(at P+(3.5*ls,1.5*ls)); "N" at N.se ljust below
+ O: dot(at (N,P)); "O" at O.s below
+ R: dot(at 1/3 between O and P);"R" at R.s below
+ M: dot(at (R,N)); "M" at M.se ljust below
+ Q: dot(at (M.x,M.y+distance(M,N)/distance(N,O)*distance(P,O)));"Q" at Q.e ljust
+ line from P to Q then to N then to O
+ B: line to P chop -0.3
+ line from M to N
+ Pu: line from R to Q chop 0 chop -0.3
+ H: line from P to N chop 0 chop -0.3
+ X: dot(at Intersect_(Pu,H)); "X" at X.se ljust below
+ thinlines_
+ RightAngle(Q,M,N)
+ RightAngle(Q,N,H.end)
+ RightAngle(N,O,B.start)
+ ArcAngle(N,P,Q,0.4); "svg_beta" at last arc.ne above ljust
+ ArcAngle(O,P,N,0.5); "svg_alpha" at last arc.start+(5bp__,8bp__)
+ ArcAngle(R,Q,N,0.5); "svg_alpha" at last arc.start+(8bp__,-5bp__)
+ ] with .sw at Fig2.e+(-0.4,-0.7)
+
+Fig4: [ ls = 2/3 # local scale
+ A: Here; "A" at A above
+ B: A+(-1*ls,-3.5*ls); "B" at B below rjust
+ C: B+(4.6*ls,0); "C" at C below ljust
+ AB: line from A to B
+ BC: line from B to C
+ CA: line from C to A
+
+ 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)
+ S: move from A to (sin(angleLAC/2),-cos(angleLAC/2))
+ AW: line from A to Intersect_(S,BC)
+ W: Here; "W" at W below rjust
+
+ perpto(C,AB,N); "N" at N above rjust
+ CN: line from C to N; RightAngle(C,N,B)
- ] with .nw at Fig3.ne+(0.2,0.2)
+ 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__)
+
+ thinlines_
+ Equidist3(B,L,N,CC1,c1rad); C1: circle rad c1rad at CC1
+ Equidist3(B,W,N,CC2,c2rad); C2: circle rad c2rad at CC2
+ Equidist3(B,C,N,CC3,c3rad); C3: circle rad c3rad at CC3
+ Equidist3(W,C,M,CC4,c4rad); C4: circle rad c4rad at CC4
+ thicklines_
+
+ Z: LCintersect(AW,CC2,C2.rad); "Z" at Z+(-5bp__,-5bp__)
+ HZ: move from H to Z
+ Y: LCintersect(HZ,CC4,C4.rad,R); "Y" at Y above
+ X: LCintersect(HZ,CC2,C2.rad); "X" at X above rjust
+
+ Loopover_(`P',`dot(at P)',X,Y,Z)
+
+ line dashed from X to Y chop -linewid/2
+ RightAngle(A,Z,Y)
+ ] with .w at Fig3.e+(-0.4,0.8)
.PE
diff --git a/graphics/circuit_macros/examples/svg/LoglogSVG.m4 b/graphics/circuit_macros/examples/svg/LoglogSVG.m4
index 37e6d746c6..b010b7bd41 100644
--- a/graphics/circuit_macros/examples/svg/LoglogSVG.m4
+++ b/graphics/circuit_macros/examples/svg/LoglogSVG.m4
@@ -88,7 +88,7 @@ Cons: [
#gen_init
svg_font(Helvetica,10pt__)
-#svg_rot_init(test)
+#vg_rot_init(test)
svg_rot_init(LoglogSVG)
divert(-1)
@@ -519,7 +519,7 @@ Left: line from dtop(yearmin,tonsmin) to dtop(yearmin,tonsmax)
move to dtop(yearmin,y)
if y<2 then {{ line right htic }}
sprintf("%g",y) wid 5bp__ rjust }
- svg_rot(90,"Tonnes of oil equivalent per capita" at Left-(0.3,0))
+ svg_rot(90,"Tonnes of oil equivalent per capita",at Left-(0.3,0))
Right: line from dtop(yearmax,tonsmin) to dtop(yearmax,tonsmax)
for p=0 to popmax do {
@@ -585,16 +585,16 @@ Cl: "Coal" wid 20bp__ at dtop(2000,0.36+3pt__)
"Oil" wid 15bp__ at dtop(2000,0.9)
"Gas" wid 20bp__ at dtop(2000,1.41)
"Wood" wid 20bp__ at dtop(1889,0.15)
- svg_rot(50,"Population" at dtop(1975,0.9))
+ svg_rot(50,"Population",at dtop(1975,0.9))
brpos = 2017
Q: brace(down_ 2.96 with .c at dtop(brpos,1.03))
- svg_rot(90,"90 %" at Q.c+(15bp__,2bp__))
- svg_rot(90,"nonrenewable" at Q.c+(26bp__,2bp__))
+ svg_rot(90,"90 %",at Q.c+(15bp__,2bp__))
+ svg_rot(90,"nonrenewable",at Q.c+(26bp__,2bp__))
R: brace(down_ 0.28 with .c at dtop(brpos,.09))
[svg_rot(90,"10 %")] ht 15bp__ wid 10bp__ at R.c+(15bp__,4bp__)
- svg_rot(90,"renewable" at R.c+(26bp__,17bp__))
+ svg_rot(90,"renewable",at R.c+(26bp__,17bp__))
linethick_(0.6)
arrow <- from dtop(1998,1.55) left 0.15 up 0.2
diff --git a/graphics/circuit_macros/examples/svg/Makefile b/graphics/circuit_macros/examples/svg/Makefile
index 0b01e8bc61..c3144811dc 100644
--- a/graphics/circuit_macros/examples/svg/Makefile
+++ b/graphics/circuit_macros/examples/svg/Makefile
@@ -75,9 +75,9 @@ CCTSVG = \
ex01SVG.svg ex02SVG.svg ex03SVG.svg ex04SVG.svg ex05SVG.svg ex06SVG.svg \
ex08SVG.svg ex09SVG.svg ex10SVG.svg ex11SVG.svg ex12SVG.svg \
ex15SVG.svg ex16SVG.svg ex17SVG.svg ex18SVG.svg ex21SVG.svg \
- expSVG.svg fetSVG.svg graysurfSVG.svg lcctSVG.svg \
+ expSVG.svg fetSVG.svg graysurfSVG.svg keyboardSVG.svg lcctSVG.svg \
pwrsupplySVG.svg quickSVG.svg randomSVG.svg recycleSVG.svg relaycoilSVG.svg \
- roseSVG.svg sfgSVG.svg shapesSVG.svg paletteSVG.svg \
+ roseSVG.svg sfgSVG.svg shapesSVG.svg SmithchartSVG.svg paletteSVG.svg \
thyristorSVG.svg ujtSVG.svg UNOSVG.svg wormSVG.svg XORSVG.svg Np.svg
examplesSVG.html: examplesSVG.htmx
@@ -114,14 +114,14 @@ tstSVG.html: tstSVG.htmx $(TEST).svg
xst: Incleps.png
# necessary because of rotated text:
-LoglogSVG.svg test.svg:
+LoglogSVG.svg:
m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic
$(DPIC) -v $*.pic > $*.svg
m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic
$(DPIC) -v $*.pic > $*.svg
grep '<\!-- width' $*.svg | sed -e 's%<\!-- *%%' -e 's% *-->%%' > $*.siz
-ConnectorsSVG.svg cscSVG.svg test.svg:
+ConnectorsSVG.svg cscSVG.svg SmithchartSVG.svg test.svg:
m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic
$(DPIC) -v $*.pic > $*.svg
m4 $(M4LIBS) $*.m4 | sed -e '/^\%/d' > $*.pic
diff --git a/graphics/circuit_macros/examples/svg/PconnSVG.m4 b/graphics/circuit_macros/examples/svg/PconnSVG.m4
index 43fb2d20eb..7cef1f5619 100644
--- a/graphics/circuit_macros/examples/svg/PconnSVG.m4
+++ b/graphics/circuit_macros/examples/svg/PconnSVG.m4
@@ -45,14 +45,11 @@ P2: [
`"(,GC)"' at last [].s below
C12: pconnex(,GCF) with .w at last [].e + (0.2,0)
`"(,GCF)"' at last [].s below
-] with .nw at P1.C1.sw + (0,-0.35)
-
-P3:[
- C4: pconnex(,P)
+ C4: pconnex(,P) with .w at last [].e + (0.2,0)
`"(,P)"' at last [].s below
C11: pconnex(,PF) with .w at last [].e+(0.2,0)
`"(,PF)"' at C11.s below
-] with .nw at P2.C9.sw + (0,-0.35)
+] with .nw at P1.C1.sw + (0,-0.35)
command "</g>" # end font
diff --git a/graphics/circuit_macros/examples/svg/SmithchartSVG.m4 b/graphics/circuit_macros/examples/svg/SmithchartSVG.m4
new file mode 100644
index 0000000000..eb47e6585e
--- /dev/null
+++ b/graphics/circuit_macros/examples/svg/SmithchartSVG.m4
@@ -0,0 +1,222 @@
+.PS
+# Smithchart.m4
+gen_init
+#https://utah.instructure.com/courses/684846
+#https://www.youtube.com/watch?v=RptPsP8hS4g
+#https://www.youtube.com/watch?v=UUk1R01uEoE
+##https://www.youtube.com/watch?v=TsXd6GktlYQ
+
+scalefactor = 6.5/2 # to vary the final chart diameter
+scalefactor = 6.5/2*3/4 # 3/4 scale for svg examples
+# Basic definitions
+define Rac {($1/($1+1),0)*scalefactor} # centre of const ra circle
+define rar {1/abs($1+1)*scalefactor} # radius
+define Xac {(1,1/($1))*scalefactor} # centre of const xa circle
+define xar {1/abs($1)*scalefactor} # radius
+define Rc {CRc[$1*100]} # Rc circle indexed by value
+define Xc {CXc[$1*100]} # Xc circle indexed by value
+define grayline {outlined graystring($1)}
+define arct {arc thick $1}
+
+# `SGamma(ra,xa) chart location of complex value'
+define(`SGamma',`(ifelse(`$2',0,`Rc($1).w',
+ `Cintersect(Rac(`$1'),rar(`$1'),Xac(`$2'),xar(`$2'), dnl
+ ifelse(substr(`$2',0,1),-,R))'))')
+# 1-piece Ra arc
+define(`RaArc1',`ifinstr(`$1',to,for ix=`$1' do,ix=`$1';) {
+ Rc(ix): arct(`$2') grayline(`$2'g) dnl
+ from SGamma(ix,`$3') to SGamma(ix,-(`$3')) with .c at Rac(ix)}')
+# 2-piece Ra arc
+define(`RaArc2',`ifinstr(`$1',to,for ix=`$1' do,ix=`$1';) {
+ Rc(ix): arct(`$2') grayline(`$2'g) dnl
+ from SGamma(ix,`$3') to SGamma(ix,`$4') with .c at Rac(ix)
+ arct(`$2') grayline(`$2'g) dnl
+ from SGamma(ix,-(`$4')) to SGamma(ix,-(`$3')) with .c at Rac(ix)}')
+# Positive and negative Xa arcs
+define(`XaArc2',`ifinstr(`$1',to,for ix=`$1' do,ix=`$1';) {
+ Xc(ix): arct(`$2') grayline(`$2'g) dnl
+ from SGamma(`$3',ix) to SGamma(`$4',ix) with .c at Xac(ix)
+ Xc(-ix): arct(`$2') grayline(`$2'g) dnl
+ cw from SGamma(`$3',-ix) to SGamma(`$4',-ix) with .c at Xac(-ix)}')
+
+define(`Smithchart',`[
+iflatex(s_init(tst)
+ command "{\tiny")
+ifsvg(svg_font(sans-serif,10bp__)
+ svg_rot_init(SmithchartSVG))
+
+ thk = 1.2 # wicth of thick lines (pt)
+ thn = 0.4 # thin lines
+ thkg = 0.33 # weight of thick lines
+ thkg =0.5
+ thng = 0.4 # weight of thin lines
+ thng = 0.6
+
+C: circle thick thk rad rar(0) at (0,0)
+ line thick thk grayline(thkg) from C.w to C.e
+
+Rc(50): circle thick thk grayline(thkg) rad rar(50) at Rac(50)
+Loopover_(`term',`RaArc1(patsubst(term,:,`,'))',
+ 20:thn:50,
+ 30 to 40 by 10:thn:50,
+ 20:thk:20,
+ 12 to 18 by 2:thn:20,
+ 10:thn:50,
+ 10:thk:20,
+ 6 to 9:thn:10,
+ 5:thk:10,
+ 2.2 to 4.81 by 0.2:thn:5,
+ 4:thn:20,
+ 4:thk:5,
+ 3:thn:10,
+ 3:thk:5,
+ 2:thn:20,
+ 2:thk:5,
+ 1.1 to 1.91 by 0.2:thn:2,
+ 1.2 to 2.01 by 0.2:thk:2,
+ 1:thn:10,
+ 1:thk:5,
+ 0.2 to 1.81 by 0.2:thn:5,
+ 0.2 to 0.81 by 0.2:thk:2,
+ 0.6 to 0.91 by 0.1:thk:1,
+ 0.55 to 0.951 by 0.1:thn:1,
+ 0.1 to 0.91 by 0.2:thn:2,
+ 0.1 to 0.91 by 0.2:thk:1,
+ 0.22 to 0.481 by 0.02:thn:0.5,
+ 0.01 to 0.191 by 0.01:thn:0.2,
+ 0.05 to 0.151 by 0.1:thk:0.2)
+
+Loopover_(`term',`RaArc2(patsubst(term,:,`,'))',
+ 0.05 to 0.451 by 0.1:thn:1:0.5,
+ 0.02 to 0.181 by 0.02:thn:0.5:0.1)
+
+Xc(50): arct(thk) cw grayline(thkg) from C.e \
+ to SGamma(0,50) with .c at Xac(50)
+Xc(-50): arct(thk) grayline(thkg) from C.e \
+ to SGamma(0,-50) with .c at Xac(-50)
+
+Loopover_(`term',`XaArc2(patsubst(term,:,`,'))',
+ 10 to 20 by 10:thn:0:50,
+ 7 to 9 by 2:thn:0:10,
+ 2 to 18 by 2:thn:0:20,
+ 0.2 to 4.81 by 0.2:thn:0:5,
+ 1.1 to 1.91 by 0.2:thn:0:2,
+ 1 to 4:thn:0:10,
+ 0.1 to 0.91 by 0.2:thn:0:2,
+ 0.22 to 0.481 by 0.02:thn:0:0.5,
+ 0.55 to 0.951 by 0.1:thn:0:1,
+ 10 to 20 by 10:thk:0:20,
+ 5:thk:0:10,
+ 1.2 to 1.81 by 0.2:thk:0:2,
+ 1 to 4:thk:0:5,
+ 0.2 to 0.81 by 0.2:thk:0:2,
+ 0.1 to 0.91 by 0.2:thk:0:1)
+
+Loopover_(`term',`XaArc2(patsubst(term,:,`,'))',
+ 0.05 to 0.451 by 0.1:thn:0.5:1,
+ 0.02 to 0.181 by 0.02:thn:0:0.5,
+ 0.02 to 0.191 by 0.01:thn:0:0.2, dnl 0.02 should be 0.01
+ 0.05 to 0.151 by 0.1:thk:0:0.2)
+dnl these avoid TeX arithmetic overflow:
+ line thick thn grayline(thng) from SGamma(0,0.01) to SGamma(0.2,0.01)
+ line thick thn grayline(thng) from SGamma(0,-0.01) to SGamma(0.2,-0.01)
+ dot(at C,,1,grayline(thkg))
+
+dnl Internal labels start here
+ textht = C.wid/120
+# Horizontal axis
+Loopover_(`t',`box wid textht ht textht*1.5 colored "white" \
+ with .se at Rc(t).w+(-2bp__,2bp__)
+ r_text(90,"t",at Rc(t).w+(-textht/3,textht*1.5))',
+ 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9, 1,1.2,1.4,1.6,1.8, 2,3,4,5,10,20,50)
+# Xc=1 labels
+Loopover_(`tt',
+ `define(`m4ta',patsubst(tt,:.*))define(`m4vl',patsubst(tt,.*:))dnl
+ X: SGamma(m4vl,1)
+ M: move from Rc(m4vl) to X; ax = lin_ang(M)*rtod_-90 #; print ax
+ r_text(m4ta,m4vl,at X+(Rect_(textht*2,ax+30)))
+ Y: X-Rc(m4vl); X: Rc(m4vl)+(Y.x,-Y.y)
+ r_text(-m4ta,m4vl,at X+(Rect_(textht*1.7,-(ax+30)))) ',
+ 10:0.2, 19:0.4, 26:0.6, 32:0.8, 37:1)
+# right-side circumference
+Loopover_(`tt',
+ `define(`m4ta',patsubst(tt,:.*))define(`m4vl',patsubst(tt,.*:))dnl
+ X: Xc(m4vl).start; ax = atan2(X.y,X.x)*rtod_ ; # print round_(ax)
+ r_text(m4ta,m4vl,at X+(Rect_(textht*2,ax-120)))
+ if m4vl>=2 then {
+ r_text(-m4ta,m4vl,at (X.x,-X.y)+(Rect_(textht*1.5,-ax+135))) }\
+ else { r_text(-m4ta,m4vl,at (X.x,-X.y)+(Rect_(textht*2,-ax+150))) } ',
+ 6:20, 11:10, 23:5, 28:4, 37:3, 53:2, 58:1.8, 64:1.6, 71:1.4, 80:1.2, 90:1)
+# left-side circumference
+Loopover_(`tt',
+ `X: Xc(m4Lx*0.1).start; # print round_(atan2(X.y,X.x)*rtod_-180)
+ r_text(-patsubst(tt,:,`,'),at X+(Rect_(textht*1.7,-m4Lx*11+40)))
+ r_text( patsubst(tt,:,`,'),at (X.x,-X.y)+(Rect_(textht*2.1,m4Lx*11-30))) ',
+ 11:0.1, 23:0.2, 33:0.3, 44:0.4, 53:0.5, 62:0.6, 70:0.7, 77:0.8, 84:0.9)
+# Ra=1 labels
+Loopover_(`tt',`X: SGamma(1,m4Lx*0.2)
+ M: move from Rac(1) to X; # print round_(lin_ang(M)*rtod_-180)
+ r_text(-eval(m4Lx*11),ifelse(m4Lx,5,1,0.eval(m4Lx*2)),
+ at X+(Rect_(textht*1.5,-m4Lx*11+40)))
+ r_text( eval(m4Lx*11),ifelse(m4Lx,5,1,0.eval(m4Lx*2)),
+ at (X.x,-X.y)+(Rect_(textht*2,m4Lx*11-30))) ',
+ 11:0.2, 23:0.4, 33:0.6, 44:0.8, 53:1)
+
+ textht *=0.9
+# Wavelength circle and tics
+ wvsep = textht*3/2
+ wltic = C.wid/120
+ circle thick thn grayline(thkg) diam C.diam+wltic/2+wvsep*11 at C
+W: circle thick thn grayline(thkg) diam C.diam+wvsep*8 at C
+ for tc=0 to 249 do {ax = 180-tc/250*360; line thick thn grayline(thkg) \
+ from W+(Rect_(W.rad+wltic/2,ax)) to W+(Rect_(W.rad-wltic/2,ax)) }
+# Wavelength circle labels
+for_(0,49,1,
+ `ifelse(eval(m4x<5),1,,
+ `r_text(eval(90-m4x*180/25),ifelse(m4x,0,0,eval(m4x<10),1,0.0`'m4x,0.`'m4x),
+ at W+(Rect_(W.rad+wltic/2+textht*0.5,180-m4x*180/25)))')
+ ifelse(eval(m4x<47),1,
+ `r_text(eval(90-m4x*180/25),ifelse(m4x,0,0,eval(m4x>40),1,0.0`'eval(50-m4x),
+ 0.`'eval(50-m4x)), at W+(Rect_(W.rad-wltic/2-textht*1.0,180-m4x*180/25)))')')
+
+ circle thick thn grayline(thkg) diam C.diam+wvsep*5 at C
+A: circle thick thn grayline(thkg) diam C.diam+wvsep*2.5 at C
+ for tc=0 to 359 by 2 do {line thick thn grayline(thkg) \
+ from A+(Rect_(A.rad+wltic/2,tc)) to A+(Rect_(A.rad,tc)) }
+for_(20,170,10,
+ `r_text(eval(-90+m4x),m4x,at A+(Rect_(A.rad+textht*0.5,m4x)))
+ r_text(eval( 90-m4x),-m4x,at A+(Rect_(A.rad+textht*1.2,-m4x)))
+ ')
+ r_text(90,180,at A-(A.rad+textht/2,0))
+Loopover_(`rca',
+ `r_text(eval(90-(180-rca/10)),eval(m4Lx*5+5),
+ at A+(Rect_(A.rad-textht*0.7,rca/10)))
+ r_text(eval(-90+(180-rca/10)),eval(-m4Lx*5-5),
+ at A+(Rect_(A.rad-textht*0.7,-rca/10))) ',
+ 195,295,392,490,588,685,782,880,967,1072,
+ 1165,1260,1352,1438,1518,1598,1645)
+
+# Internal labels
+ setrgb(thng,thng,thkg)
+ "RESISTANCE R/Zo OR CONDUCTANCE G/Yo" at C+SGamma(0.5,0)-(0,C.rad/40)
+ Loopover_(`Lttr',`ifelse(Lttr,*,,`r_text(eval(87-m4Lx*86/100),Lttr,
+ at W+(Rect_(W.rad+wltic/2+textht*0.5, 177-m4Lx*0.86))) ')',
+ W,A,V,E,L,E,N,G,T,H,S,*,T,O,W,A,R,D,*,G,E,N,E,R,A,T,O,R)
+ Loopover_(`Lttr',`ifelse(Lttr,*,,`r_text(eval(115-m4Lx*86/100),Lttr,
+ at W+(Rect_(W.rad-wltic/2-textht*1.0, 204-m4Lx*0.86))) ')',
+ W,A,V,E,L,E,N,G,T,H,S,*,T,O,W,A,R,D,*,L,O,A,D)
+ Loopover_(`Lttr',`ifelse(Lttr,*,,`define(`xa','13-m4Lx*86/100`)
+ r_text(eval(xa-90),Lttr,at A+(Rect_(A.rad+textht*0.7, xa))) ')',
+ R,E,F,L,E,C,T,I,O,N,*,C,O,E,F,F,I,C,I,E,N,T,*,A,N,G,L,E)
+ Loopover_(`Lttr',`ifelse(Lttr,*,,`define(`xa','14-m4Lx*86/100`)
+ r_text(eval(xa-90),Lttr,at A+(Rect_(A.rad-textht*0.7, xa))) ')',
+ T,R,A,N,S,M,I,S,S,I,O,N,*,C,O,E,F,F,I,C,I,E,N,T,*,A,N,G,L,E)
+ resetrgb
+
+iflatex(command "}%",
+ifsvg(command "</g>"))
+] at (0,0)')
+
+Smithchart
+
+.PE
diff --git a/graphics/circuit_macros/examples/svg/cscSVG.m4 b/graphics/circuit_macros/examples/svg/cscSVG.m4
index 8f1b954669..05cf0c70d4 100644
--- a/graphics/circuit_macros/examples/svg/cscSVG.m4
+++ b/graphics/circuit_macros/examples/svg/cscSVG.m4
@@ -1,19 +1,21 @@
.PS
#.PS 3.5
# csc.m4
+# This file includes AntiqueClock and works for PSTricks, Tikz, and SVG
gen_init
+NeedDpicTools
-skale = 3.5/3.97*0.9955
+skale = 0.878
circlerad=1.91*skale
hubrad=0.10*skale
s=0.5*skale
-define(`midnight',`26,26,112')
-define(`white',`255,255,255')
-define(`spokethick',0.1)
+define(`midnight',`0.1, 0.1, 0.44')
+define(`white',`1, 1, 1')
+define(`spokewidth',0.1)
define(`spoke',`dnl
- {line from rvec_(0,hubrad-spokethick/2) to rvec_(circlerad-0.05,0)}
- {line from rvec_(0,-(hubrad-spokethick/2)) to rvec_(circlerad-0.05,0)}')
+ {line from rvec_(0,hubrad-spokewidth/2) to rvec_(circlerad-0.05,0)}
+ {line from rvec_(0,-(hubrad-spokewidth/2)) to rvec_(circlerad-0.05,0)}')
define(`lwid',1)
define(`coord',`(s*(`$1'),s*(`$2'))')
@@ -23,7 +25,7 @@ rgbdraw(midnight,
linethick=`0.'eval(lwid*15)/(1pt__)
{circle with .c at Here
circle invis diam last circle.diam + linethick pt__ at last circle }
- linethick=spokethick/(1pt__)
+ linethick=spokewidth/(1pt__)
for angle = 0 to 330 by 30 do {
Point_(angle)
{spoke}
@@ -46,7 +48,7 @@ rgbdraw(midnight,
# Sail
thinlines_
- setrgb(midnight)
+ rgbfill(midnight,
line from coord(0.44,3.38) to coord(0.44,2.6) \
then to coord(2.1,-1.75) \
then to coord(1.22,-1.53) \
@@ -60,34 +62,33 @@ rgbdraw(midnight,
then to coord(-0.92,1.73) \
then to coord(0,2.9) \
then to coord(0.44,3.38)
+ )
# Hull
+ rgbfill(midnight,
spline from coord(2.1,-1.75) to coord(1.9,-2.2) \
then to coord(1.85,-2.3) then to coord(1.8,-2.33) \
then to coord(1,-2.5) then to coord(0,-2.6) then to coord(-0.38,-2.57) \
then to coord(-2.13,-2.4)
line to coord(-2.2,-2.05) then to coord(2.1,-1.75)
-# spline to coord(-1,-2.08) then to coord(0.55,-1.77)
- line to coord(2.1,-1.75)
- resetrgb
- setrgb(white)
- spline from coord(-2.2,-2.05) to coord(-1,-2.08) then to coord(0.55,-1.77)
- line to coord(-2.2,-2.05)
- resetrgb
- linethick=`0.'eval(lwid*15)/(1pt__)
-
+ spline to coord(-1,-2.08) then to coord(0.55,-1.77)
+ )
]
+
Clock: [
+# PSTricks, tikz, or svg only:
+ifelse(ifpstricks(T)`'ifpgf(T)`'ifsvg(T),T,`
#.PS
-# AntiqueClockSVG.m4
+# AntiqueClock.m4
#gen_init
-svg_font(font-family="sans-serif" font-stretch="condensed")
+#NeedDpicTools
-# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals
+iflatex(`latexcommand({\sf)')
+ifsvg(svg_font(font-family="sans-serif" font-stretch="condensed")
+# svg_rot_init(test))
+ svg_rot_init(cscSVG))
-#svg_rot_init(AntiqueClockSVG)
-#svg_rot_init(test)
-svg_rot_init(cscSVG)
+# 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
@@ -148,6 +149,7 @@ define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2
fitcurve(X,n,shaded rgbstring(0,0,0))
]')
+
define(`AntiqueClock',`[ # h,m,s,diam
# Clock size parameters:
hour = ifelse(`$1',,3,`$1')
@@ -155,8 +157,8 @@ define(`AntiqueClock',`[ # h,m,s,diam
second = ifelse(`$3',,51,`$3')
# outer radius
ifelse(`$4',,`skale=0.5; r1=2',`r1=(`$4')/2; skale=r1/4')
- r2 = r1 - 0.5*skale
- r3 = r2 - 0.14*skale
+ 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
@@ -191,32 +193,35 @@ Face: circle thick 0 fill_(1) rad r3 at C
circle rad r5 at C
circle rad r6 at C
circle rad r7 at C
+
# Ad hoc shift of rotated SVG text
- define adj { (-cosd($`'1)*textht*0.5*sign(180-($`'1)),\
- (0.25+0.25*cosd(2*($`'1)))*textht) }
+ ifsvg(`define adj {+(-cosd($`'1)*textht*0.5*sign(180-($`'1)),\
+ (0.25+0.25*cosd(2*($`'1)))*textht) }',
+ `define adj {}')
+ define adj {}
+
# Outer numbers
- textht = (r3-r4)*0.6
- for mn = -15 to 15 by 5 do { t = 90-mn/60*360
- R:(Rect_((r3+r4)/2,t))
- svg_rot(-mn/60*360,sprintf("%g",pmod(mn,60)) at C+R+adj(t))
- }
- for mn = 20 to 40 by 5 do { t = 450-mn/60*360
- R: (Rect_((r3+r4)/2,t))
- svg_rot(180-mn/60*360, sprintf("%g",pmod(mn,60)) at C+R+adj(t))
- }
+ iflatex(`command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4)')
+ ifsvg(`textht = (r3-r4)*0.6')
+ for_(-15,15,5,`aa=90-(m4x)*6
+ r_text(eval(-(m4x)*6),eval((m4x+60)%60),
+ at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
+ for_(20,40,5,`aa=450-(m4x)*6
+ r_text(eval(180-m4x*6),m4x,at C+(Rect_((r3+r4)/2,aa)) adj(aa))')
# 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
- textht = (r5-r6)*0.6
- Loopover_(`mx',`tt = 90-(m4Lx-4)/12*360
- R: (Rect_((r5+r6)/2,tt))
- svg_rot(tt-90, "mx" at C+R+adj(tt)) ',
+ iflatex(`command sprintf("\font\innerfont=cmss12 at %4.2fin",r5-r6)')
+ ifsvg(`textht = (r5-r6)*0.6')
+ Loopover_(`mx',`aa=180-(m4Lx-1)*30
+ r_text(eval(120-m4Lx*30),iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
IX,X,XI,XII,I,II,III)
- Loopover_(`mx',`tt = 360-m4Lx*30
- R: (Rect_((r5+r6)/2,tt))
- svg_rot(tt-270, "mx" at C+R+adj(tt)) ',
+ Loopover_(`mx',`aa=360-m4Lx*30
+ r_text(eval(90-m4Lx*30), iflatex({\innerfont mx},mx),
+ at C+(Rect_((r5+r6)/2,aa)) adj(aa))',
IV,V,VI,VII,VIII)
# Inner tics
@@ -230,13 +235,15 @@ Face: circle thick 0 fill_(1) rad r3 at C
# Center
dot(at C,0.1/4*r1,1)
- ]')
+ ]') `# AntiqueClock'
Clock1: AntiqueClock(,,,3.5)
-# Clock2: AntiqueClock(4,48,07,2) at Clock1.e+(1.5,0)
+# Clock2: AntiqueClock(4,50,07,2) at Clock1.e+(1.5,0)
+
+ iflatex(`latexcommand(}%)')
+ ifsvg(`command "</g>"')
- command "</g>" # end font
#.PE
+',` "AntiqueClock.m4 requires PSTricks, Tikz-pgf, or SVG" ')
] with .sw at last [].se+(0.25,0)
-
.PE
diff --git a/graphics/circuit_macros/examples/svg/ex15SVG.m4 b/graphics/circuit_macros/examples/svg/ex15SVG.m4
index 055986740b..ca15109fa9 100644
--- a/graphics/circuit_macros/examples/svg/ex15SVG.m4
+++ b/graphics/circuit_macros/examples/svg/ex15SVG.m4
@@ -29,7 +29,7 @@ for i = 1 to n-1 do {
D: C+(Rect_(crad*g,110))
rm = crad+distance(C,D)
for r=lt to rm by lt do {
- u = (1-r/rm)*255
+ u = (1-r/rm)
if r < (1-g)*crad then { rgbdraw(u,u,u,circle rad r at D) } \
else { rgbdraw(u,u,u,arc cw from Cintersect(D,r,C,crad) \
to Cintersect(D,r,C,crad,R) with .c at D) }
diff --git a/graphics/circuit_macros/examples/svg/examplesSVG.htmx b/graphics/circuit_macros/examples/svg/examplesSVG.htmx
index a7c830ed54..f2ea0d8bc5 100644
--- a/graphics/circuit_macros/examples/svg/examplesSVG.htmx
+++ b/graphics/circuit_macros/examples/svg/examplesSVG.htmx
@@ -355,7 +355,7 @@ cfig(AudioSVG,
Audio elements)
cfig(XformSVG,
- The transformer element`,' drawing direction down)
+ Some variations of the transformer element`,' drawing direction down)
cfig(NPDTSVG,
Double throw with the m4tt`'NPDT</g> macro)
@@ -370,7 +370,7 @@ cfig(relaycoilSVG,
The m4tt`'relaycoil</g> macro)
cfig(RelaySVG,
- Some variants of the m4tt`'relay</g> macro)
+ Some variants of m4tt`'relay</g>)
cfig(JackSVG,
The m4tt`'jack</g> and m4tt`'plug</g> macros)
@@ -521,9 +521,6 @@ cfig(TubediagsSVG,
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)
@@ -540,7 +537,7 @@ cfig(DecoderSVG,
cfig(ex21SVG,
Some flip-flops)
-cfig(MultiplexerSVGfor showing
+cfig(MultiplexerSVG,
Multiplexer)
cfig(DemultiplexerSVG,
@@ -593,11 +590,6 @@ cfig(GrayCodeSVG,
Gray code 10-bit encoder disk pattern`,'
and a crossbar switch)
-<!--
-#cfig(CrossbarSVG,
-# A crossbar switch)
--->
-
cfig(ByteSVG,
Elementary splines)
@@ -639,11 +631,6 @@ cfig(LoglogSVG,
cfig(GeometrySVG,
Plane geometry examples)
-<!--
-#cfig(LyapSVG,
-# Illustrating a Lyapunov function)
--->
-
cfig(randomSVG,
Testing random numbers)
@@ -658,10 +645,8 @@ cfig(graysurfSVG,
cfig(shapesSVG,
Basic shapes)
-<!--
-#fig(AntiqueClockSVG,
-# An antique clock face)
--->
+cfig(keyboardSVG,
+ More objects drawn in relief)
cfig(cscSVG,
Conestoga Sailing Club (illustrating the filling of arbitrary shapes)`,'
@@ -696,7 +681,7 @@ cfig(SierpinskiSVG,
tests of pic macro recursion)
cfig(EscherSVG,
- Two Escher-like objects)
+ Penrose stairs and an Escher-like object)
cfig(recycleSVG,
Modest repetition and partial fill)
@@ -704,9 +689,12 @@ cfig(recycleSVG,
cfig(ex15SVG,
Simple diagrams that are easily drawn by looping)
+cfig(SmithchartSVG,
+ A Smith chart at 3/4 scale)
+
<!--
-cfig(CountingSVG,
- An example of enumeration)
+#fig(CountingSVG,
+# An example of enumeration)
-->
cfig(CrowSVG,
@@ -722,7 +710,7 @@ cfig(FlowSVG,
</p> -->
cfig(BtreeSVG,
- Binary trees)
+ Trees)
cfig(InclepsSVG,
Overlaying a figure with line graphics)
diff --git a/graphics/circuit_macros/examples/svg/icsSVG.m4 b/graphics/circuit_macros/examples/svg/icsSVG.m4
index f1eb9ae9ab..896e1008eb 100644
--- a/graphics/circuit_macros/examples/svg/icsSVG.m4
+++ b/graphics/circuit_macros/examples/svg/icsSVG.m4
@@ -246,17 +246,17 @@ define(`HDMI_micro',`[
D0`'svg_it(-), CLK`'svg_it(+), CLK_SH, CLK`'svg_it(-),
CEC, GND, SCL, SDA,svg_it(+)5V)
L1: line from Base.nw+(m4bwid*2/3-lg_pinsep,0) up plen
- svg_rot(90,"21" at last line.c +(-2bp__,0))
- svg_rot(90,"SH2" at last line.start + (4bp__,-8bp__))
+ svg_rot(90,"21",at last line.c +(-2bp__,0))
+ svg_rot(90,"SH2",at last line.start + (4bp__,-8bp__))
line from Base.nw+(m4bwid*2/3-2*lg_pinsep,0) up plen
- svg_rot(90,"20" at last line.c+(-2bp__,0))
- svg_rot(90,"SH1" at last line.start + (4bp__,-8bp__))
+ svg_rot(90,"20",at last line.c+(-2bp__,0))
+ svg_rot(90,"SH1",at last line.start + (4bp__,-8bp__))
line from Base.sw+(m4bwid*2/3-lg_pinsep,0) down plen
- svg_rot(90,"23" at last line.c+(-2bp__,0))
- svg_rot(90,"SH4" at last line.start + (4bp__,14bp__))
+ svg_rot(90,"23",at last line.c+(-2bp__,0))
+ svg_rot(90,"SH4",at last line.start + (4bp__,14bp__))
line from Base.sw+(m4bwid*2/3-2*lg_pinsep,0) down plen
- svg_rot(90,"22" at last line.c+(-2bp__,0))
- svg_rot(90,"SH3" at last line.start + (4bp__,14bp__))
+ svg_rot(90,"22",at last line.c+(-2bp__,0))
+ svg_rot(90,"SH3",at last line.start + (4bp__,14bp__))
#
`$4']')
diff --git a/graphics/circuit_macros/examples/svg/keyboardSVG.m4 b/graphics/circuit_macros/examples/svg/keyboardSVG.m4
new file mode 100644
index 0000000000..7966a7aa3b
--- /dev/null
+++ b/graphics/circuit_macros/examples/svg/keyboardSVG.m4
@@ -0,0 +1,269 @@
+.PS
+# keyboardSVG.m4
+ gen_init
+ scale=25.4 # unit is mm
+
+divert(-1)
+
+define(`kbd_u',(11mm__))
+define(`kbdrowsep',`movewid')
+define(`kbdshadewid',`(kbd_u/9)')
+
+ `kbdkey(name|text=chars,keys)
+ chars: string or string string
+ keys: wdth=expr; # base wid
+ hght=expr; # base ht
+ rad=expr; # base rad
+ shadewid=expr; # base shade wid
+ base=attribs; # base attributes
+ top=attribs; # top attributes '
+define(`kbdkey',
+ `pushkeys_(`$2',
+ wdth:kbd_u; hght:kbd_u*14/13+lthick; rad:kbd_u/10;
+ shadewid:kbdshadewid; base:fill_(0.3):N; top:fill_(0.9):N)dnl
+ [ Base: box wid m4wdth ht m4hght rad m4rad m4base
+ Top: box wid m4wdth-2*m4shadewid ht m4hght-m4shadewid-lthick \
+ rad m4rad*(kbd_u-2*m4shadewid)/(kbd_u) with .n \
+ at Base.n-(0,lthick) m4top
+ move to Top.w
+ ifelse(`$1',,,`pushkey_(`$1',text,,N)ifelse(m4text,,
+ `"iflatex(\sf) `$1'" above ljust',
+ `m4text');') `$3'
+ popdef(`m4wdth', `m4hght', `m4shadewid', `m4rad', `m4base', `m4top') dnl
+ popdef(`m4text') ] ')
+
+define(`tsmall',
+ `iflatex(`"{\sf\scriptsize `$1'}"',
+ ifelse(`$3',,")svg_fsize(`$1',ifelse(`$2',,75,`$2'))ifelse(`$3',,"))')
+
+define(`stkbdkey',
+ `iflatex(`command "{\sf\scriptsize"',`m4tmp=textht
+ textht = ifelse(`$1',,0.66*textht,`$1') ')
+ kbdkey(shift($*))
+ iflatex(`command "}%"',`textht = m4tmp')')
+
+ `enterkey(name|text=chars,keys)
+ chars: string or string string
+ keys: wdth=expr; # base wid
+ hght=expr; # base ht
+ bhght=expr; # ht of bottom part
+ rad=expr; # base rad
+ shadewid=expr; # base shade wid
+ base=attribs; # base attributes
+ top=attribs; # top attributes '
+define(`enterkey',
+ `pushkeys_(`$2',
+ wdth:kbd_u*2.26;
+ hght:kbd_u*14/13*2+kbdrowsep+linethick bp__;
+ bhght: kbd_u*14/13;
+ twdth: kbd_u*3/2;
+ rad:kbd_u/10;
+ shadewid:kbdshadewid;
+ base:fill_(0.3):N;
+ top:fill_(0.9):N)dnl
+ [ ltx = lthick; r = m4rad*(kbd_u-2*m4shadewid)/(kbd_u)
+# thick outer
+ linethick = (m4shadewid+r)/(1bp__); lth2 = lthick/2
+ NEx: Here; NE: NEx-(lth2,lth2); SE: NE-(0,m4hght-lth2*3-ltx*3/2)
+ SW: SE-(m4wdth-lthick,0)
+ W: SW+(0,m4bhght-lthick+ltx*3/2); NW: NE-(m4twdth-lthick,0); X: (NW,W)
+ d = 0.3; ro = m4rad-lth2
+ move to W; arcto(X,NW,m4rad+lth2,outlined graystring(d)); Tx:NW
+ Loopover_(`PK',`arcto(Tx,PK,ro,outlined graystring(d));Tx:PK',NE,SE,SW,W,X)
+ linethick = ltx
+# outer outline
+ NE: NEx; SE: NE-(0,m4hght+ltx); SW: SE-(m4wdth,0)
+ W: SW+(0,m4bhght); NW: NE-(m4twdth,0); X: (NW,W)
+ m4enteroutline(m4rad,,m4rad)
+# thick inner
+ linethick = m4shadewid/(1bp__)+linethick; lth2 = lthick/2
+ NE: NEx-(m4shadewid+lth2,lth2+ltx); SE: (NE,SE)+(0,m4shadewid*3/2)
+ SW: SE-(m4wdth-m4shadewid*3,0); W: SW+(0,m4bhght-m4shadewid*2-ltx*3/2);
+ NW: NE-(m4twdth-m4shadewid*3,0); X: (NW,W)
+ c = 0.9; ri = r-lth2
+ move to W; arcto(X,NW,ri+lth2*2,outlined graystring(c)); Tx:NW
+ Loopover_(`PK',`arcto(Tx,PK,ri,outlined graystring(c));Tx:PK',NE,SE,SW,W,X)
+ N: 1/2 between NW and NE
+ line from N to (N,SE) thick (NE.x-NW.x)/(1bp__) outlined graystring(c)
+ SSW: 1/2 between SW and W
+ line from SSW to (SE,SSW) thick (W.y-SW.y)/(1bp__) outlined graystring(c)
+# inner outline
+ NE: NE+(lth2,lth2); SE: SE+(lth2,-lth2); SW: SW-(lth2,lth2)
+ W: W+(-lth2,lth2); NW: NW+(-lth2,lth2); X: (NW,W)
+ linethick = ltx
+ m4enteroutline(ri,,ri+lth2*2)
+ move to (X,(1/2 between SW and W));
+ ifelse(`$1',,,`pushkey_(`$1',text,,N)dnl
+ ifelse(m4text,,`"iflatex(\sf) `$1'" above ljust',`m4text')')
+ popdef(`m4wdth', `m4hght', `m4bhght', `m4twdth', `m4shadewid', `m4rad',
+ `m4base', `m4top', `m4bhght' ) popdef(`m4text')dnl
+ `$3' ] ')
+define(`m4enteroutline',`move to W+(`$1',0); arcto(X,NW,`$3',`$2'); Tx: NW
+ Loopover_(`PP',`arcto(Tx,PP,`$1',`$2'); Tx: PP',NE,SE,SW,W,X)')
+define(`m4enterup',`[ u = ifelse(`$1',,kbd_u*0.3)
+ line right u/4 then up u/2 then right u/6 then up u/2 left u/4+u/6 \
+ then down u/2 left u/4+u/6 then right u/6 then down u/2 then right u/4
+ ]')
+
+define(`kbdsymb',`iflatex("\tt\char`$1'",`dsvg_symb(`$1')')')
+define(`m4kbdarrow',`arrow thick 1.5 ht kbd_u/5 wid kbd_u/5')
+
+divert(0)dnl
+
+define dsvg_symb {"&#$1;"}
+
+maxpswid = 25*kbd_u
+movewid = kbd_u/11
+
+define(`rshift',` at Here+(ifelse(`$1',,`kbd_u/8',`$1'),0) ')
+
+iflatex(`command "{\small\sf"',
+ `ifsvg(svg_font(Arial,kbd_u*16/13/4,0bp__))
+ textht=kbd_u/4 ')
+
+Row2: [
+ textoffset = kbd_u/8
+ Loopover_(`KK',`kbdkey(text=KK); move',
+ kbdsymb(126) ljust kbdsymb(96) ljust,
+ Loopover_(`NN',`kbdsymb(NN) ljust "m4Lx" ljust,',33,64,35,36,37,94,38,42,40)
+ kbdsymb(41) ljust "0" ljust,
+ kbdsymb(95) ljust "-" ljust,
+ kbdsymb(43) ljust "=" ljust,
+ kbdsymb(124) ljust kbdsymb(92) ljust,
+ "" )
+ m4kbdarrow left kbd_u*0.5 at last [].Top
+ ]
+Row1: [
+ kbdkey(tsmall(Esc,,N)); move right_ last [].wid+movewid*2
+ Loopover_(`KK',`kbdkey(KK); move',F1,F2,F3,F4)
+ move right_ last [].wid/2
+ Loopover_(`KK',`kbdkey(KK); move',F5,F6,F7,F8)
+ move right_ Row2.wid-Here.x-4*last [].wid-4*movewid
+ Loopover_(`KK',`kbdkey(KK); move',F9,F10,F11,F12)
+ ] with .sw at Row2.nw+(0,2*kbdrowsep)
+Row3: [
+# Uparrow: kbdkey(,,m4kbdarrow up kbd_u/2 at Top)
+ Tab: kbdkey(text=tsmall(Tab) rshift ljust,wdth=kbd_u*1.6,
+ [ A: m4kbdarrow left kbd_u/2; line thick A.thick up A.wid at A.end
+ A: m4kbdarrow right A.len at A-(0,kbd_u/2)
+ line thick A.thick up A.wid at A.end ] with .w at Top ); move
+ Loopover_(`KK',`KK: kbdkey(KK); move',Q,W,E,R,T,Y,U,I,O,P)
+ textoffset = kbd_u/8
+ kbdkey(text=kbdsymb(123) ljust kbdsymb(91) ljust); move
+ kbdkey(text=kbdsymb(125) ljust kbdsymb(93) ljust); move
+ w = Row2.wid-Here.x
+ R: box invis wid w-movewid ht last [].Base.ht
+ ] with .nw at Row2.sw-(0,kbdrowsep)
+Row4: [
+ Capslock: kbdkey(text=tsmall(Caps Lock) rshift ljust,
+ wdth=Row3.Tab.wid+Row3.Q.wid/3;); move
+ Loopover_(`KK',`KK: kbdkey(KK); move',A,S,D,F,G,H,J,K,L)
+ textoffset = kbd_u/8
+ kbdkey(text=kbdsymb(58) ljust kbdsymb(59) ljust); move
+ kbdkey(text=kbdsymb(34) ljust kbdsymb(39) ljust); move
+ ] with .nw at Row3.sw-(0,kbdrowsep)
+ Enter: enterkey(text=tsmall(Enter),,
+ m4kbdarrow <- from last ""+(kbd_u/2,0) \
+ right kbd_u/2 then up kbd_u/5 ) \
+ with .ne at (Row2.e,Row3.n)-(movewid,0)
+Row5: [
+ ShiftL: kbdkey(text=tsmall(Shift) at 0.4 between Top.w and Top.e,
+ wdth=kbd_u*2.4, m4enterup at 0.15 between Top.w and Top.e); move
+ Loopover_(`KK',`KK: kbdkey(KK); move',Z,X,C,V,B,N,M)
+ textoffset = kbd_u/8
+ kbdkey(text=kbdsymb(60) ljust kbdsymb(44) ljust); move
+ kbdkey(text=kbdsymb(62) ljust kbdsymb(46) ljust); move
+ kbdkey(text=kbdsymb(63) ljust kbdsymb(47) ljust); move
+ v = Row2.wid-Here.x-kbd_u-movewid*2
+ ShiftR: kbdkey(text=tsmall(Shift) at 1/2 between Top.w and Top.e,wdth=v,
+ m4enterup at 0.15 between Top.w and Top.e); move
+ kbdkey(); move
+ ] with .nw at Row4.sw+(0,-kbdrowsep)
+Row6: [
+ w = 22/18*kbd_u
+ CtrlL: kbdkey(text=tsmall(Ctrl) rshift ljust,wdth=w); move
+ kbdkey(,wdth=w); move
+ kbdkey(text=tsmall(Alt) rshift ljust,wdth=w); move
+ s = Row2.wid-(7*w+8*movewid)
+ kbdkey(,wdth=s); move
+ kbdkey(text=tsmall(Alt) rshift ljust,wdth=w); move
+ kbdkey(,wdth=w); move
+ kbdkey(,wdth=w); move
+ CtrlR: kbdkey(text=tsmall(Ctrl) rshift ljust,wdth=w); move
+ ] with .nw at Row5.sw+(0,-kbdrowsep)
+Arrowkeys: [ iflatex(`command "{\sf\scriptsize"',`textht *=0.66')
+Row1:[ textoffset = kbd_u/20
+ kbdkey(text=`"Print" ljust "Screen" ljust "SysRQ" ljust'); move
+ textoffset = kbd_u/12
+ kbdkey(text="Scroll" ljust "Lock" ljust); move
+ kbdkey(text="Pause" ljust "Break" ljust); move
+ ]
+Row2: [ textoffset = kbd_u/12
+ kbdkey(text="Insert" ljust); move
+ kbdkey(text=tsmall(Home) ljust); move
+ kbdkey(text="Page" ljust "Up" ljust); move
+ ] with .nw at Row1.sw-(0,2*kbdrowsep)
+Row3: [ textoffset = kbd_u/12
+ Delete: kbdkey(text="Delete" ljust); move
+ End: kbdkey(text="End" ljust); move
+ kbdkey(text="Page" ljust "Down" ljust); move
+ ] with .nw at Row2.sw+(0,-kbdrowsep)
+Row5: [
+ move right Row3.End.w.x + movewid
+ Uparrow: kbdkey(,,m4kbdarrow up kbd_u/2 at Top)
+ ] with .nw at Row3.sw-(0,Row3.Delete.ht+2*kbdrowsep)
+Row6: [
+ kbdkey(,,m4kbdarrow left kbd_u/2 at Top); move
+ kbdkey(,,m4kbdarrow down kbd_u/2 at Top); move
+ kbdkey(,,m4kbdarrow right kbd_u/2 at Top); move
+ ] with .nw at Row5.sw-(0,kbdrowsep)
+
+ iflatex(`command "}%"',`textht *=(1/0.66)')
+ ] with .nw at Row1.ne+(movewid,0)
+Keypad: [ move down_ Arrowkeys.n.y-Arrowkeys.Row2.e.y; right_
+ textoffset = kbd_u/8
+Row2:[
+ kbdkey(text=tsmall(Num) ljust tsmall(Lock) ljust); move
+ iflatex(`command "{\large"',`textht *=1.5')
+ kbdkey(text=kbdsymb(47) ljust); move
+ kbdkey(text=kbdsymb(42) ljust); move
+ kbdkey(text=kbdsymb(45) ljust); move
+ iflatex(`command "}"')
+ ]
+Row3:[ textoffset = kbd_u/12
+ kbdkey(text="7" ljust tsmall(Home) ljust); move
+ kbdkey(text="8" ljust "" ljust,,m4kbdarrow up_ kbd_u/3 \
+ at 3/4 between Top.ne and Top.sw); move
+ kbdkey(text="9" ljust tsmall(PgUp) ljust); move
+ ] with .nw at Row2.sw+(0,-kbdrowsep)
+Row4:[ textoffset = kbd_u/12
+ kbdkey(text="4" ljust "" ljust,,m4kbdarrow left kbd_u/3 \
+ at 0.7 between Top.ne and Top.sw); move
+ kbdkey(text="5" ljust "" ljust); move
+ Six: kbdkey(text="6" ljust "" ljust,,m4kbdarrow right kbd_u/3 \
+ at 0.7 between Top.ne and Top.sw); move
+ ] with .nw at Row3.sw+(0,-kbdrowsep)
+Row5:[ textoffset = kbd_u/12
+ kbdkey(text="1" ljust tsmall(End) ljust); move
+ kbdkey(text="2" ljust "" ljust,,m4kbdarrow down kbd_u/3 \
+ at 0.7 between Top.ne and Top.sw); move
+ kbdkey(text="3" ljust tsmall(PgDn) ljust); move
+ ] with .nw at Row4.sw+(0,-kbdrowsep)
+Row6:[ textoffset = kbd_u/12
+ kbdkey(text="0" ljust tsmall(Ins) ljust,
+ wdth=Row4.wid-Row4.Six.wid-2*movewid); move
+ kbdkey(text=kbdsymb(46) ljust tsmall(Del) ljust); move
+ ] with .nw at Row5.sw+(0,-kbdrowsep)
+Col4: [ textoffset = kbd_u/12
+ iflatex(`command "{\large"',`textht *=1.5')
+ kbdkey(text="+" ljust,hght=Row3.n.y-Row4.s.y); move
+ iflatex(`command "}"',`textht /=1.5')
+ kbdkey(text=tsmall(Enter) ljust,hght=Row5.n.y-Row6.s.y) \
+ with .nw at last [].sw - (0,kbdrowsep)
+ ] with .ne at (Row2.e,Row3.n)
+
+ ] with .nw at Arrowkeys.ne+(movewid,0)
+
+iflatex(`command "}%"',
+ifsvg(`command "</g>"'))
+.PE
diff --git a/graphics/circuit_macros/examples/svg/sfgSVG.m4 b/graphics/circuit_macros/examples/svg/sfgSVG.m4
index 793db01ae8..666f311ca4 100644
--- a/graphics/circuit_macros/examples/svg/sfgSVG.m4
+++ b/graphics/circuit_macros/examples/svg/sfgSVG.m4
@@ -82,21 +82,54 @@ G4: [sfg_init( 2.0,0.25/2 ) # change node spacing and increase node size
N2: sfgnode(,svg_fsize(2,120),,invis)
{ sfgarc(to N1 ->,,,ccw,s1) }
{ "p(1-p)svg_gamma+2`'svg_nu" at last [].M+(11bp__,0) above }
- { svg_choose(2,1) at last [].M+(-29bp__,8bp__) }
+ { svg_choose(2,1) at last [].M+(-19bp__,8bp__) }
{ sfgarc(to N0 ->,(1-p)svg_sup(2)`svg_gamma',above,ccw,s2) }
sfgline(right_ sfg_wid,`svg_nu'+2`svg_lambda',below,->)
N3: sfgnode(,svg_fsize(3,120),,invis)
{ sfgarc(to N2 ->,,,ccw,s1) }
{ "p`'svg_sup(2)(1-p)svg_gamma+3`'svg_nu" at last [].M+(0bp__,0) above }
- { svg_choose(3,2) at last [].M+(-43bp__,8bp__) }
+ { svg_choose(3,2) at last [].M+(-33bp__,8bp__) }
{ sfgarc(to N1 ->,,,ccw,s2) }
{ "p(1-p)`'svg_sup(2)`'svg_gamma" at last [].M+(8bp__,0) above }
- { svg_choose(3,1) at last [].M+(-26bp__,8bp__) }
+ { svg_choose(3,1) at last [].M+(-16bp__,8bp__) }
{ sfgarc(to N0 ->,(1-p)svg_sup(3)`svg_gamma',above,ccw,s2) }
sfgline(right_ sfg_wid*2/3,`svg_nu'+3`svg_lambda',below,->)
{"..." wid 0.3 ljust}
] with .nw at G3.sw+(0,-0.1)
+# https://tex.stackexchange.com/questions/637455/tikz-how-to-set-exact-position-of-node
+G5: [sfg_init( 1.75,0.25/2 ) # change node spacing and increase node size
+ Dstar: sfgnode(,* )
+ D0: sfgnode(at Dstar+(2,0),svg_small(&lt;&gt;)svg_sub(0) )
+ sfgline(,
+ svg_it(1-r`'svg_sub(`x-1,x')-q`'svg_sup(i)svg_sub(x-1`,'x,,,-0.8ex)),,->)
+ Ddots: sfgnode(,... )
+ sfgline(,svg_it(1-r`'svg_sub(x-4`,'x)-q`'svg_sup(i)svg_sub(x-4`,'x,,,-0.8ex)),
+ ,->)
+ D5: sfgnode(,svg_small(&lt;&gt;)svg_sub(5) )
+ DD: sfgnode(at D0+(0,-1.0),svg_symbol(&``#''8224;) )
+ sfgself(at Dstar,L,,,,0.5)
+ "svg_it(1-i`'svg_sub(x)-q`'svg_sub(x)svg_sup(a,,,-0.8ex))" wid 45bp__ \
+ at Dstar + (-0.3,0.25)
+ sfgself(at DD,D,1,above_,,0.5)
+ sfgself(at D5,R,,,,0.5)
+ "svg_it(1-q`'svg_sub(x)svg_sup(i,,,-0.8ex)-r`'svg_sub(x))" wid 47bp__ \
+ at D5 + (0.3,0.25)
+ sfgarc(from D0 to Dstar ->,svg_it(r`'svg_sub(x`,'x)),below_,ccw)
+ sfgarc(from Dstar to D0 ->,svg_it(i`'svg_sub(x)),above_,ccw)
+ sfgarc(from Dstar to DD ->,svg_it(q`'svg_sub(x)svg_sup(a,,,-0.8ex)),
+ above_ ljust_,ccw)
+ sfgline(from D0 to DD,svg_it(q`'svg_sup(i)svg_sub(x`,'x,,,-0.8ex)),ljust,->)
+ sfgarc(from Ddots to Dstar,svg_it(r`'svg_sub(j`,'x)),below_,ccw,,->)
+ sfgarc(from Ddots to DD ->,svg_it(q`'svg_sup(i)svg_sub(x-j`,'x)),
+ above_ rjust_,)
+ sfgarc(from D5 to Dstar ->,svg_it(r`'svg_sub(x)),below_,ccw)
+ sfgarc(from D5 to DD ->,svg_it(q`'svg_sup(i)svg_sub(x,,,-0.8ex)),
+ above_ rjust_,)
+ ] with .nw at G4.sw+(0,-0.15)
+#howbox_(,"G5")
+
+
move from (T.w,G4.s)-(7bp__,6bp__) to B.ne+(15bp__,6bp__)
command "</g>" # end font
.PE
diff --git a/graphics/circuit_macros/examples/tubedefs.m4 b/graphics/circuit_macros/examples/tubedefs.m4
index af47e307b7..fa79c05904 100644
--- a/graphics/circuit_macros/examples/tubedefs.m4
+++ b/graphics/circuit_macros/examples/tubedefs.m4
@@ -4,11 +4,11 @@ divert(-1)
# Size parameters
define(`tubediam',`dimen_')
-define(`tubethick',`2')
+define(`tubethick',`2') # thick line thickness
define(`tubepindiam',`tubediam*3/8')
define(`tubeplatelen',`tubediam/2')
define(`tubegridlen',`tubediam*7/12')
-define(`tubcathlen',`tubeplatelen-tubethick bp__')
+define(`tubecathlen',`tubeplatelen-tubethick bp__')
define(`tubedotthick',`1.2')
define(`tubedotdiam',`tubediam/6')
define(`tgap',`tubediam*3/20')
@@ -125,7 +125,7 @@ define(`tubegrid',`dashline(ifelse(`$1',,`right tubegridlen',`$1'),
`tubecathode(length,R)'
define(`tubecathode',`[
- box invis wid ifelse(`$1',,tubcathlen,`$1') ht tubeplatelen/6
+ box invis wid ifelse(`$1',,tubecathlen,`$1') ht tubeplatelen/6
ifinstr(`$2',R,
`line thick tubethick from last box.nw to last box.sw \
then to last box.se then to last box.ne',
diff --git a/graphics/circuit_macros/gpic.m4 b/graphics/circuit_macros/gpic.m4
index d1a151d759..78c643dc5b 100644
--- a/graphics/circuit_macros/gpic.m4
+++ b/graphics/circuit_macros/gpic.m4
@@ -1,7 +1,7 @@
divert(-1)
gpic.m4 Initialization for gpic.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/lib3D.m4 b/graphics/circuit_macros/lib3D.m4
index df80c32b28..8413b335ea 100644
--- a/graphics/circuit_macros/lib3D.m4
+++ b/graphics/circuit_macros/lib3D.m4
@@ -3,7 +3,7 @@ lib3D.m4 Macros for rotation, projection, and other
operations on argument triples representing
3D vectors or colors.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/libSLD.m4 b/graphics/circuit_macros/libSLD.m4
index 015fd0cf3f..3ad627c4cf 100644
--- a/graphics/circuit_macros/libSLD.m4
+++ b/graphics/circuit_macros/libSLD.m4
@@ -2,7 +2,7 @@ divert(-1)
libSLD.m4 Draft macros for single-line diagram elements
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -14,14 +14,15 @@ divert(-1)
# These *DRAFT* definitions are for single-line diagram (SLD) elements
# with or without attached circuit breakers or slashes. Many other elements
# applicable to SLD drawings are already in libcct.m4. The contributions
-# and suggestions of Benjamin Vilmann are acknowledged with thanks.
+# and suggestions of Benjamin Vilmann and Peter Jan Randewijk are
+# acknowledged with thanks.
# The line
# include(libSLD.m4)
# loads these definitions for use in a diagram.
# Notes for 1-terminal SLD elements:
-# Argument 1 is normally the linespec of the stem to set the element direction
+# Argument 1 is normally the linespec of the stem to set the direction
# and length.; e.g., D1: sl_disk draws a default disk with stem named D1.
# For a 0-length stem (which has undefined direction):
# arg1 can also be U, D, L, R (for up, down, left, right),
@@ -30,13 +31,9 @@ divert(-1)
# 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 a plain stem is drawn. A non-blank argument 3
-# is C for a default closed breaker in the stem, O for an open breaker,
-# or X, /, or \ to put these symbols in the box; otherwise, key-value
-# pairs specify breaker details. If argument 3 begins with S: or Sn:
-# (where n is an integer) then an n-line slash symbol is drawn.
+# If argument 3 is blank then a plain stem is drawn as described below.
# The element body (head) can be named with name= . The default name is Head.
-# It is overlaid with or contained in a [] block.
+# The head is overlaid with or contained in a [] block.
# Notes for 2-terminal SLD elements:
# These obey the normal Circuit_macro two-terminal conventions.
@@ -45,27 +42,27 @@ divert(-1)
# e.g., name=Name; text="text"; wdth=expr; ...
# Except for sl_drawout and sl_breaker which do not have series breakers
# or slashes, nonblank arguments 3 and 4 put a breaker slash symbol
-# in the input and output respectively.
+# in the input and output respectively as described below.
-# Notes for attached breakers:
+# Notes for attached breakers and slashes:
# 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, C a closed
-# breaker; and an X, /, or \ inserts the corresponding mark in the box;
-# otherwise, the argument contains key-value pairs to specify the
-# details of the box; e.g., box=dotted 2bp__ shaded "green"
-# The separation of the breaker from the element body or head is given
-# by parameter sl_breakersep_ or the key sep=expr.
-# Arguments 3 and 4 of the two-terminal elements that begin with S: or Sn:
-# (where n is an integer) and argument 3 of the 1-terminal elements
-# specify an n-slash symbol rather than a breaker.
+# the 1-terminal elements specify a breaker in the input, output,
+# and stem respectivlely. A non-blank argument is C for a default
+# closed breaker in the stem, O for an open breaker, or X, /, or \ to
+# put these symbols in the box; if the argument begins with S: or Sn:
+# (where n is an integer) then an n-line slash symbol is drawn rather
+# than a breaker; otherwise or in addition, key-value pairs specify
+# details of the object. The separation of the breaker or slash
+# from the element body or head is given by parameter sl_breakersep_
+# or key sep=expr. If this key is in the body or head keys then it
+# applies to both 2-terminal stem lines; it can also be given for each
+# stem individually.
# Notes for composite elements within a [ ] block:
-# The current transformer macro sl_ct is composite, with internal
-# labels defined as appropriate to the element. The macro sl_transormer3
-# is composite, with 3 principal termianls and other defined points.
-# Macro sl_busbar is also composite, with internal labels P1 to Pnp,
-# Start, and End.
+# The current transformer macro sl_ct has internal labels defined as
+# appropriate to the element. The macro sl_transormer3 has 3 principal
+# termianls and other defined points. Macro sl_busbar has internal
+# labels P1 to Pnp, Start, and End.
define(`sldlib_')
ifdef(`libcct_',,`include(libcct.m4)divert(-1)')
@@ -84,7 +81,7 @@ define(`sl_loadwid_',`dimen_*0.32') # load width
define(`sl_loadlen_',`dimen_*0.45') # load length
define(`sl_transcale_',1) # transformer body scale factor
define(`sl_busthick_',linethick*2) # sl_bus line thickness
-define(`sl_busindent_',`min(dimen_/5,rp_len/5)') # bus end extension
+define(`sl_busindent_',`min(dimen_/5,rp_len/5)') # busbar end indent
# One-terminal elements ###################################################
@@ -460,11 +457,12 @@ define(`sl_inverter',
breaker keys or S[n]: keys )'
`Draw the breaker slash in the element stem'
define(`m4_one',
-`pushkeys_(`$4',lgth:sl_breakersize_; sep:sl_breakersep_)dnl
+`pushkeys_(`$4',lgth:sl_breakersize_; sep:-1)define(`m4s_p',`ifelse(m4sep,(-1),
+ `pushkey_(`$3',sep,sl_breakersep_)`'m4sep`'popdef(`m4sep')',m4sep)')dnl
M4end: last line.end
{ifelse(regexp(`$4',^ *S),-1,
`ifelse(`$4',,,
- `line to last line.end-vec_(m4lgth+m4sep,0)
+ `line to last line.end-vec_(m4lgth+m4s_p,0)
pushdef(`m4bri',`ifelse(`$4',C,,`$4',O,`box=fill_(0)')')dnl
sl_breaker(to rvec_(m4lgth,0),`$4';m4bri;name=Br) popdef(`m4bri')')
$1(to M4end,`$3')',
@@ -473,7 +471,7 @@ define(`m4_one',
`define(`m4in',`ifelse(`$4',S,1,`$4',S:,1,
`patsubst(`$4',.*S\([0-9][0-9]*\):?.*,\1)')')dnl
define(`m4inkey',`patsubst(`$4',^ *S[0-9]*:?)') pushkey_(m4inkey,name,SL,N)
- sl_slash(at M4end-vec_(m4lgth+m4sep*2/3,0),
+ sl_slash(at M4end-vec_(m4lgth+m4s_p*2/3,0),
m4inkey;name=m4name,m4in:) popdef(`m4name')')')}
popdef(`m4lgth',`m4sep')')
@@ -559,37 +557,41 @@ define(`sl_drawout',
(Default breaker names are BrI and BrO)
(Default slash names are SLI and SLO)'
define(`m4_two',
-`pushkeys_(`$4',lgth:ifelse(`$2',,sl_ttboxlen_*2,`$2'); sep:sl_breakersep_)dnl
+`pushkeys_(`$4',lgth:ifelse(`$2',,sl_ttboxlen_*2,`$2'); sep:-1)dnl
+ define(`m4s_pI',`ifelse(m4sep,(-1),
+ `pushkey_(`$5',sep,sl_breakersep_) m4sep popdef(`m4sep')',m4sep)')dnl
+ define(`m4s_pO',`ifelse(m4sep,(-1),
+ `pushkey_(`$6',sep,sl_breakersep_) m4sep popdef(`m4sep')',m4sep)')dnl
ifelse(regexp(`$5',^ *S),-1,
`define(`m4il',`ifelse(`$5',,0,
- `pushkey_(`$5',lgth,sl_breakersize_) m4lgth popdef(`m4lgth')')')dnl
+ `pushkeys_(`$5',lgth:sl_breakersize_) m4lgth popdef(`m4lgth')')')dnl
define(`m4ol',`ifelse(`$6',,0,
`pushkey_(`$6',lgth,sl_breakersize_) m4lgth popdef(`m4lgth')')')dnl
- eleminit_(`$3',max(elen_,m4lgth+m4il*3.5+m4ol*3.5+m4sep*2))
+ eleminit_(`$3',max(elen_,m4lgth+m4il*3.5+m4ol*3.5+m4s_pI+m4s_pO))
M4end: last line.end
- { line to last line.c-vec_((m4lgth + m4il + m4ol + m4sep*2)/2,0)
+ { line to last line.c-vec_((m4lgth + m4il + m4ol + m4s_pI+m4s_pO)/2,0)
pushdef(`m4bri',`ifelse(`$5',,,`$5',C,,`$5',O,`box=fill_(0)')')dnl
ifelse(`$5',,,`sl_breaker(to rvec_(m4il,0),`$5';m4bri;name=BrI)
- line to rvec_(m4sep,0)')
+ line to rvec_(m4s_pI,0)')
$1(to rvec_(m4lgth,0),`$4',,,`$7',`$8')
pushdef(`m4bro',`ifelse(`$6',,,`$6',C,,`$6',O,`box=fill_(0)')')dnl
- ifelse(`$6',,,`line to rvec_(m4sep,0)
+ ifelse(`$6',,,`line to rvec_(m4s_pO,0)
sl_breaker(to rvec_(m4ol,0),`$6';m4bro;name=BrO)')
line to M4end popdef(`m4bri', `m4bro') }',
- `eleminit_(`$3',max(elen_,m4lgth+m4sep*4)) ; dnl slashes
+ `eleminit_(`$3',max(elen_,m4lgth+(m4s_pI+m4s_pO)*2)) ; dnl slashes
M4end: last line.end
{ $1(to M4end,`$4',,,`$7',`$8') }
ifelse(`$5',,,`define(`m4in',`ifelse(`$5',S,1,`$5',S:,1,
`patsubst(`$5',.*S\([0-9][0-9]*\):?.*,\1)')')dnl
define(`m4inkey',`patsubst(`$5',^ *S[0-9]*:?)')dnl
pushkey_(m4inkey,name,SLI,N)dnl
- {sl_slash(at rvec_(rp_len/2-m4lgth/2-m4sep,0),
+ {sl_slash(at rvec_(rp_len/2-m4lgth/2-m4s_pI,0),
m4inkey;name=m4name,m4in:)} popdef(`m4name')')
ifelse(`$6',,,`define(`m4on',`ifelse(`$6',S,1,`$6',S:,1,
`patsubst(`$6',.*S\([0-9][0-9]*\):*.*,\1)')')dnl
define(`m4onkey',`patsubst(`$6',^ *S[0-9]*:?)')dnl
pushkey_(m4onkey,name,SLO,N)dnl
- {sl_slash(at rvec_(rp_len/2+m4lgth/2+m4sep,0),
+ {sl_slash(at rvec_(rp_len/2+m4lgth/2+m4s_pO,0),
m4onkey;name=m4name,m4on:)} popdef(`m4name')') ')
line invis to M4end popdef(`m4lgth', `m4sep') ')
@@ -618,6 +620,7 @@ define(`m4ch_two',
scale=expr (default 1);
grnd=degrees (type S or N);
stemlgth=expr (type L or S);
+ sep=expr (type S slashes to head separation);
type=N omits the stem and slashes
type=Sn draws n slashes, e.g., type=S2
Arg3 sets the stem direction'
@@ -635,15 +638,15 @@ define(`sl_ct',`[ Origin: Here
line from L.c to L.c+vec_(0,-m4stemlgth)
Tc: Here popdef(`m4stemlgth')',
m4type,S,
- `C: circle rad sourcerad_*m4scale at Origin
- pushkey_(`$2',stemlgth,C.rad*4)dnl
+ `C: circle rad sourcerad_*m4scale*0.5 at Origin
+ pushkeys_(`$2',stemlgth:C.rad*6; sep:C.rad*2)dnl
Stem: line from C to C+vec_(m4stemlgth,0) chop C.rad chop 0; Tc: Here
ifelse(m4grnd,,,`ground(at C+(Rect_(C.rad,m4grnd)),,,m4grnd)'); \
pushdef(`m4n',`ifelse(m4type,S,2,`eval(patsubst(m4type,.*S))')')dnl
- sl_slash(at C+vec_(C.rad*2.5,0),,m4n:rp_ang*rtod_)
- popdef(`m4stemlgth',`m4n')',
+ sl_slash(at C+vec_(C.rad+m4sep,0),,m4n:rp_ang*rtod_)
+ popdef(`m4stemlgth',`m4sep',`m4n')',
m4type,N,
- `C: circle rad sourcerad_*m4scale at Origin
+ `C: circle rad sourcerad_*m4scale*0.5 at Origin
ifelse(m4grnd,,,`ground(at C+(Rect_(C.rad,m4grnd)),,,m4grnd)') ')
resetdir_ popdef(`m4type', `m4scale', `m4grnd' )
] with .Origin ifelse(`$1',,at Here,`$1') ')
@@ -662,11 +665,11 @@ define(`sl_busbar',
[ tmp_ang = rp_ang
eleminit_(`$1',(m4npoints-1)*dimen_)
Start: last line.start; End: last line.end
+ Line: line from Start to End m4line; C: Line.c
M: move from Start to End chop m4indent
for_(1,m4npoints,1,
`P`'m4x: (m4x-1)/(m4npoints-1) between M.start and M.end dnl
ifinstr(m4port,D,` ;dot(at P`'m4x)')')
- Line: line from Start to End m4line; C: Line.c
point_(tmp_ang) ] popdef(`m4line', `m4port', `m4indent') ')
`sl_slash( at position, keys, [n:]R|L|U|D|degrees)
diff --git a/graphics/circuit_macros/libcct.m4 b/graphics/circuit_macros/libcct.m4
index 3c4128b6d3..16ae9ba91e 100644
--- a/graphics/circuit_macros/libcct.m4
+++ b/graphics/circuit_macros/libcct.m4
@@ -1,7 +1,7 @@
divert(-1)
libcct.m4
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -1727,7 +1727,7 @@ SW: rvec_(adc_ht/2,-adc_ht/2)
`$7']')
`diode(linespec,
- B|CR|D|F|G|L|LE[R]|P[R]|S|Sh|T|U|V|v|w|Z|chars,
+ B|b|CR|D|F|G|L|LE[R]|P[R]|S|Sh|T|U|V|v|w|Z|chars,
[R][E])
Adding K to arg2 draws open arrowheads
Adding M draws a mid-arrowhead crossbar
@@ -1742,6 +1742,7 @@ define(`diode',
define(`m4cts',`ifelse(
dma_,,LACR,
dma_,B,uLAZQuR,
+ dma_,b,uLAzQuR,
dma_,CR,LACRrb,
dma_,D,LuAHdQR,
dma_,F,LFR,
@@ -1806,6 +1807,7 @@ define(`diode',
[u|d]v varicap diode-capacitor curved plate
Y bilateral core
Z zener bar
+ z zener bar outlined
arg 2: f= fill the arrowhead
M=arrowhead crossbar
R=right orientation
@@ -1936,6 +1938,13 @@ define(`m4gen_d',`{dnl
to rvec_(0,-m4dv/2-m4dy) \
then to rvec_(0, m4dv/2+m4dy) \
then to rvec_(m4dv/4,m4dv/2+m4dy)}')
+ sc_draw(`ddna_',z,dnl Outlined zener bar
+ `{line from rvec_(-m4dv/4,-m4dv/2-m4dy-lthick*2) \
+ to rvec_( lthick*0.7,-m4dv/2-m4dy) \
+ then to rvec_( lthick*0.7, m4dv/2+m4dy+lthick) }
+ {line from rvec_( m4dv/4, m4dv/2+m4dy+lthick*2) \
+ to rvec_(-lthick*0.7, m4dv/2+m4dy) \
+ then to rvec_(-lthick*0.7,-m4dv/2-m4dy-lthick) }')
ifinstr(ddna_,Q,dnl left arrowhead
`sc_draw(`ddna_',Qc,`define(`m4Qc')')sc_draw(`ddna_',Q,`undefine(`m4Qc')')dnl
define(`m4dn',`ifelse(m4a,u,m4dv/2,m4a,d,-m4dv/2,0)')dnl
@@ -1967,7 +1976,6 @@ define(`m4gen_d',`{dnl
`line from 0.5 between M4_s and M4_e to M4_e \
chop m4dh ifelse(m4a,,/2,m4a,d,/2+m4dv/4) chop 0')
')dnl
-
`em_arrows( type,degrees,length)
type=[N|I|E][D] N=nonionizing, I=ionizing,
E=simple; D=dot on arrow stem
@@ -2790,8 +2798,8 @@ define(`reversed',`eleminit_(`$2')
`resized(factor,`macro name in quotes',args)
multiply element body size by factor'
-define(`resized',`define(`m4resiztmp',dimen_)define(`dimen_',(dimen_)*(`$1'))dnl
- $2(shift(shift($@))) define(`dimen_',m4resiztmp)')
+define(`resized',`pushdef(`dimen_',(dimen_)*(`$1'))dnl
+ $2(shift(shift($@))) popdef(`dimen_')')
`variable(`element', type, [+|-]angle,
length, at position)
@@ -3674,6 +3682,7 @@ define(`earphone',`[ setdir_($1,R)
In2: Here
In3: rvec_(0,-m4h/8)')
`$4'; resetdir_ ]')
+
`Signal-flow graph macros: labeled node,
directed labeled chopped straight line,
directed labeled chopped arc, and a self
@@ -3746,8 +3755,8 @@ define(`sfgarc',`eleminit_(`$1',sfg_wid)
`arc m4c_l patsubst(patsubst(`$1',.*<-,<-),->.*$,->) ifelse(`$4',ccw,ccw,cw)\
from Cintersect(Start,sfg_rad,C,arcrd,ifelse(`$4',ccw,R)) \
to Cintersect(C,arcrd,End,sfg_rad,ifelse(`$4',ccw,R)) with .c at C')
- ifelse(`$2',,,`{move to M; "iflatex(`$ `$2'$',` $2')" ifelse(`$3',,
- `sfgabove',`$3')}')
+ ifelse(`$2',,,`move to M; "iflatex(`$ `$2'$',` $2')" ifelse(`$3',,
+ `sfgabove',`$3')')
] with .Start at last line.start
move to last line.end
')
@@ -3767,7 +3776,7 @@ define(`sfgself',`[ Origin: Here
ifelse(`$7',,`{ arrow m4c_l from rvec_(0,ifelse(`$5',cw,,-)sfg_aht/2) \
to rvec_(0,ifelse(`$5',cw,-)sfg_aht/2) ht sfg_aht wid sfg_awid }')
ifelse(`$3',,,
- `"iflatex(`$ `$3'$',` $3')" ifelse(`$4',,`sfgabove',`$4')') }
+ `{"iflatex(`$ `$3'$',` $3')" ifelse(`$4',,`sfgabove',`$4')}') }
m4sfgselfcurve(,
ifelse(`$5',ccw,`ifinstr(`$7',->,<-)',`ifinstr(`$7',<-,<-)'))
resetdir_ ] with .Origin ifelse(`$1',,at Here,`$1')
diff --git a/graphics/circuit_macros/libgen.m4 b/graphics/circuit_macros/libgen.m4
index 7862d04bb4..9fe00c721c 100644
--- a/graphics/circuit_macros/libgen.m4
+++ b/graphics/circuit_macros/libgen.m4
@@ -2,7 +2,7 @@ divert(-1)
libgen.m4 Base macros for dpic and gpic diagrams
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -44,7 +44,7 @@ dnl define(`HOMELIB_',`D:\Dwight\lib')
`NeedDpicTools( path )
If path is empty then HOMELIB_ is used
e.g. NeedDpicTools or NeedDpicTools(/home/lib/)'
-define(`NeedDpicTools',`if "dpictools_" != "1" then { copy dnl
+define(`NeedDpicTools',`if dpicopt > 0 then { copy dnl
ifelse(`$1',,`"HOMELIB_`'dpictools.pic"',`"`$1'dpictools.pic"') }')
Processor shortcuts
@@ -184,7 +184,7 @@ define(`SIdefaults',
define(`latexcommand',`command "ifmpost(verbatimtex) `$1' ifmpost(etex)"')
define(`m4announceprocessor',`dnl Do not change the format of the next line:
-`#' `$1' Version 9.8: ifelse(m4picprocessor,gpic,`Gpic',
+`#' `$1' Version 9.9: ifelse(m4picprocessor,gpic,`Gpic',
m4postprocessor,pstricks,`PSTricks',
m4postprocessor,pgf,`TikZ PGF',
m4postprocessor,mfpic,`Mfpic',
@@ -821,8 +821,8 @@ define(`m4Delch',
If string contains abc=expr; then
pushdef(`m4abc',(expr)) otherwise
pushdef(`m4abc',(default)).
- setkey_ uses define() instead of pushdef{}.
- Nonblank arg4 omits the parentheses.'
+ Nonblank arg4 omits the parentheses. The
+ expr and val may not contain ;'
define(`pushkey_',
`pushdef(`m4xt',index(`$1',`$2'=))ifelse(m4xt,-1,
`pushdef(key_prefix`'$2,`ifelse(`$3',,,ifelse(`$4',,(`$3'),`$3'))')',
@@ -833,6 +833,14 @@ define(`pushkey_',
substr(m4sktmp,0,index(m4sktmp,;))))')')dnl
popdef(`m4xt')')
+ `setkey_(string,key,default,[N])
+ string contains semicolon-separated
+ terms of the form key=val
+ If string contains abc=expr; then
+ define(`m4abc',(expr)) otherwise
+ define(`m4abc',(default)).
+ Nonblank arg4 omits the parentheses. The
+ expr and val may not contain ;'
define(`setkey_',
`define(`m4xt',index(`$1',`$2'=))ifelse(m4xt,-1,
`define(key_prefix`'$2,`ifelse(`$3',,,ifelse(`$4',,(`$3'),`$3'))')',
@@ -845,20 +853,32 @@ popdef(`m4xt')')
define(`key_prefix',`m4') # Could be locally redefined
- `pushkeys_(string,keysequence)
- Invoke pushkey_ on a sequence of terms.
- setkeys_(string,keysequence)
- Invoke setkey_ on a sequence of terms.
- Arg 2 is a sequence of semicolon (;)-separated
- terms of the form
- identifier:default value:N
- containing up to 3 fields separated by : '
-define(`pushkeys_',`Loopover_(`M4Z',`pushkey_(`$1',patsubst(M4Z,:,`,'))dnl',
- patsubst(`$2',;,`,'))')
-define(`setkeys_',`Loopover_(`M4Z',`setkey_(`$1',patsubst(M4Z,:,`,'))dnl',
- patsubst(`$2',;,`,'))')
-
- `String with exact typeset dimensions:
+ `pushkeys_(string,keysequence,keysep,itemsep)
+ Invoke pushkey_ on a sequence of terms.
+ Arg 2 is a sequence of terms separated by
+ arg3 (default ;) of the form
+ identifier:default value:N
+ containing up to 3 fields separated by arg 4
+ (default :). The separators may not appear
+ elsewhere in the terms.'
+define(`pushkeys_',`Loopover_(`M4Z',
+ `pushkey_(`$1',patsubst(M4Z,ifelse(`$4',,:,`$4'),`,'))dnl',
+ patsubst(`$2',ifelse(`$3',,;,`$3'),`,'))')
+
+ `setkeys_(string,keysequence,keysep,itemsep)
+ Invoke setkey_ on a sequence of terms.
+ Arg 2 is a sequence of terms separated by
+ arg3 (default ;) of the form
+ identifier:default value:N
+ containing up to 3 fields separated by arg 4
+ (default :). The separators may not appear
+ elsewhere in the terms.'
+define(`setkeys_',`Loopover_(`M4Z',
+ `setkey_(`$1',patsubst(M4Z,ifelse(`$4',,:,`$4'),`,'))dnl',
+ patsubst(`$2',ifelse(`$3',,;,`$3'),`,'))')
+
+ `s_box(text or other latex)
+ String with exact typeset dimensions:
Requires s_init(name), sinclude(filename.dim),
boxdims.sty, and processing twice. If there
are two or more args they are given to
@@ -873,29 +893,35 @@ ifelse(index(`$1',"),0,`substr(`$1',1,eval(len(`$1')-2))',`$1')}dnl
"ifelse(`$2',,,`,shift($@))') \
wid s_wd(,`textwid') ht s_ht(,`textht')+s_dp')')
- `r_text(text,degrees)
+ `r_text(degrees,text,at position)
(requires PSTricks, pgf, or svg)'
define(`r_text',`define(`m4txt',
-`ifelse(index(`$1',"),0,`substr(`$1',1,eval(len(`$1')-2))',`$1')')dnl
+`ifelse(index(`$2',"),0,`substr(`$2',1,eval(len(`$2')-2))',`$2')')dnl
ifelse(ifpstricks(T)`'ifpgf(T)`'ifsvg(T),T,
-`define(`m4rtang',`ifelse(`$2',,90,`$2')')dnl
-ifsvg(`svg_rot(m4rtang,"m4txt")')dnl
-ifpstricks(`"\rput[c]{m4rtang}(0,0){m4txt}"')dnl
-ifpgf(`"\pgftext[rotate=m4rtang]{m4txt}"')',"m4txt")')
+`define(`m4rtang',`ifelse(`$1',,90,`$1')')dnl
+ifsvg(`svg_rot(m4rtang,"m4txt",`$3')')dnl
+ifpstricks(`"\rput[c]{m4rtang}(0,0){m4txt}" `$3'')dnl
+ifpgf(`"\pgftext[rotate=m4rtang]{m4txt}" `$3'')',
+"m4txt")')
define(`text_ang',90)
- `Like s_box but text is rotated text_ang degrees
+ `rs_box([angle=degrees;] text or other latex)
+ Like s_box but text is rotated text_ang degrees
+ (default 90) unless the angle= key is given.
+ The key must be a decimal number.
(requires PSTricks or pgf)'
define(`rs_box',
`define(`m4_k',ifdef(`m4_k',incr(m4_k),1))dnl
ifelse(`$2',,,`sprintf(')"ifdef(`s_name',,`{\bf !!}')dnl
\defboxdim{s_name`'_`'m4_k}{dnl
-ifelse(index(`$1',"),0,`substr(`$1',1,eval(len(`$1')-2))',`$1')}dnl
-ifpstricks(`\rput[c]{text_ang}(0,0)')ifpgf(`\pgftext[rotate=text_ang]'){dnl
-ifelse(index(`$1',"),0,`substr(`$1',1,eval(len(`$1')-2))',`$1')}"dnl
+pushkey_(`$1',angle,text_ang,N)define(`rs_arg',patsubst(`$1',.*;))dnl
+ifelse(index(rs_arg,"),0,`substr(rs_arg,1,eval(len(rs_arg)-2))',rs_arg)}dnl
+ifpstricks(`\rput[c]{m4angle}(0,0)')ifpgf(`\pgftext[rotate=m4angle]'){dnl
+ifelse(index(rs_arg,"),0,`substr(rs_arg,1,eval(len(rs_arg)-2))',rs_arg)}"dnl
ifelse(`$2',,,`,shift($@),shift($@))') \
- wid s_wd(,textwid)*cosd(text_ang) + (s_ht(,textht)+s_dp)*sind(text_ang) \
- ht (s_ht(,textht)+s_dp)*cosd(text_ang)+s_wd(,textwid)*sind(text_ang)')
+ wid s_wd(,textwid)*cosd(m4angle) + (s_ht(,textht)+s_dp)*sind(m4angle) ht \
+ (s_ht(,textht)+s_dp)*cosd(m4angle) \
+ +s_wd(,textwid)*sind(m4angle)popdef(`m4angle')')
`Initialize string index: s_init(name)'
define(`s_init',`define(`s_name',`$1')')
@@ -1490,7 +1516,7 @@ define(`Cintersect',
define(`m4cls',`(m4cdx^2+m4cdy^2)')dnl
define(`m4cq',`((m4cls+m4Cr1^2-m4Cr2^2)/2)')dnl
(m4cq/m4cls between `$1' and `$3') ifinstr(`$5',R,-,+)\
- (vscal_(sqrt(max(0,m4cls*m4Cr1^2-m4cq^2))/m4cls,-m4cdy,m4cdx))')
+ (vscal_(sqrt(abs(m4cls*m4Cr1^2-m4cq^2))/m4cls,-m4cdy,m4cdx))')
define(`cintersect',`Cintersect($@)')
`LCintersect(Name of line,Centre,rad,[R])
@@ -1749,6 +1775,8 @@ define(`graystring',`rgbstring(`$1',`$1',`$1')')
`outlined string' or `shaded string'
(mpost,PSTricks,pdf,tikz-pgf,postscript,svg
only)'
+ `The 1: after rgb is a divisor for the values
+ (xcolor manual p 16)'
ifelse(
m4postprocessor,pstricks,`define(`rgbstring',`ifelse(`$2',,`"$1"',
`sprintf("{rgb,1:red,%7.5f;green,%7.5f;blue,%7.5f}",`$1',`$2',`$3')')')',
@@ -1768,7 +1796,6 @@ m4postprocessor,postscript,`define(`rgbstring',
[name],[D][F])
define colour for lines and text.
arg5 (svg only): D=draw, F=fill
- SVG values are 0 to 255
see also \usepackage{latexcolors} and
latexcolor.com'
define(`setrgb',`pushdef(`r_',`$1')pushdef(`g_',`$2')pushdef(`b_',`$3')dnl
@@ -1780,9 +1807,9 @@ ifelse(m4postprocessor,pstricks,
m4postprocessor,svg,`
command "<g " \
ifinstr(`$5',F,,
- `+ sprintf("stroke=\"rgb(%g,%g,%g)\" ",round_(r_),round_(g_),round_(b_))') \
+ `+ sprintf("stroke=\"rgb(%g,%g,%g)\" ",color255(r_,g_,b_))') \
ifinstr(`$5',D,,
- `+ sprintf("fill=\"rgb(%g,%g,%g)\"", round_(r_),round_(g_),round_(b_))') \
+ `+ sprintf("fill=\"rgb(%g,%g,%g)\"", color255(r_,g_,b_))') \
+ ">"',
m4postprocessor,pgf,`
command sprintf("\definecolor{m4cl_}{rgb}{%7.5f,%7.5f,%7.5f}%%",r_,g_,b_)
@@ -1832,7 +1859,7 @@ ifelse(m4postprocessor,pstricks,
shift(shift(shift($@)))
command "}%"',
m4postprocessor,svg,
- `setrgb(`$1',`$2',`$3',,ifsvg(F))
+ `setrgb(`$1',`$2',`$3',,F)
shift(shift(shift($@)))
resetrgb',
m4postprocessor,pgf,
diff --git a/graphics/circuit_macros/liblog.m4 b/graphics/circuit_macros/liblog.m4
index 3e0397b73a..f89e39b486 100644
--- a/graphics/circuit_macros/liblog.m4
+++ b/graphics/circuit_macros/liblog.m4
@@ -1,7 +1,7 @@
divert(-1)
liblog.m4 Logic gates
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/mfpic.m4 b/graphics/circuit_macros/mfpic.m4
index 7776a7fdce..1670be9104 100644
--- a/graphics/circuit_macros/mfpic.m4
+++ b/graphics/circuit_macros/mfpic.m4
@@ -1,7 +1,7 @@
divert(-1)
mfpic.m4 Initialization for mfpic.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/mpost.m4 b/graphics/circuit_macros/mpost.m4
index 843b1b0b95..8e3acae6ec 100644
--- a/graphics/circuit_macros/mpost.m4
+++ b/graphics/circuit_macros/mpost.m4
@@ -1,7 +1,7 @@
divert(-1)
mpost.m4 Initialization for metapost.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/pgf.m4 b/graphics/circuit_macros/pgf.m4
index e794a15e3e..73dc439b94 100644
--- a/graphics/circuit_macros/pgf.m4
+++ b/graphics/circuit_macros/pgf.m4
@@ -1,7 +1,7 @@
divert(-1)
pgf.m4 Initialization for Tikz-pgf.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/postscript.m4 b/graphics/circuit_macros/postscript.m4
index 606cc96258..3b724e380a 100644
--- a/graphics/circuit_macros/postscript.m4
+++ b/graphics/circuit_macros/postscript.m4
@@ -1,7 +1,7 @@
divert(-1)
postscript.m4 Initialization for Postscript output.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/psfrag.m4 b/graphics/circuit_macros/psfrag.m4
index 5af564a316..78b117ac40 100644
--- a/graphics/circuit_macros/psfrag.m4
+++ b/graphics/circuit_macros/psfrag.m4
@@ -2,7 +2,7 @@ divert(-1)
psfrag.m4 Initialization for dpic -f processing:
Postscript with psfrag strings
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/pstricks.m4 b/graphics/circuit_macros/pstricks.m4
index 728194721c..822bd94c83 100644
--- a/graphics/circuit_macros/pstricks.m4
+++ b/graphics/circuit_macros/pstricks.m4
@@ -1,7 +1,7 @@
divert(-1)
pstricks.m4 Initialization for PSTricks.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
diff --git a/graphics/circuit_macros/svg.m4 b/graphics/circuit_macros/svg.m4
index dfa968891f..73f144594f 100644
--- a/graphics/circuit_macros/svg.m4
+++ b/graphics/circuit_macros/svg.m4
@@ -1,7 +1,7 @@
divert(-1)
svg.m4 Initialization for SVG output.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -207,6 +207,7 @@ define(`svg_pound',`svg_symbol(&`#'35;)')
define(`svg_circ',`svg_symbol(&`#'710;)')
define(`svg_deg',`svg_symbol(&`#'176;)')
define(`svg_equiv',`svg_symbol(&`#'8801;)')
+define(`svg_tilde',`svg_symbol(&`#'126;)')
')
define(`svgcolor',`sprintf("rgb(%g,%g,%g)",\
@@ -242,7 +243,7 @@ define(`svg_rot_init',`
| sed -e \"s/x=\\"\([0-9.]*\)\\" y=\\"\([0-9.]*\)\\".*/\1 \2/\" dnl
> _file_.cor" )
if retcode != 0 then { print "
- Awk failure
+ Awk failure.
Awk and sed are required by svg_rot to rotate svg text.
" }
svgrot_k = 0
@@ -254,7 +255,7 @@ define(`svg_rot_init',`
svgrot_i = 0
ifdef(`svg_rot_',,`
-# `svg_rot(degrees,"text" [at position])
+# `svg_rot(degrees,"text",[at position])
# Rotate text degrees ccw
# Requires svg_rot_init(filename)
# which uses both awk and sed.
@@ -263,15 +264,36 @@ define(`svg_rot_init',`
if "$`'1" != "" then { svg_rang = -($`'1) } else { svg_rang = -90 }
if svgrot_k != 0 then { svgrot_i +=1
command sprintf("<g transform=\"rotate(%g %g %g)\">",svg_rang,\
- svg_rx[svgrot_i],svg_ry[svgrot_i]) }\
+ svg_rx[svgrot_i]+textht/2*sind(svg_rang),\
+ svg_ry[svgrot_i]+textht/2*(1-cosd(svg_rang))) }\
else { command sprintf("<g transform=\"rotate(%g)\">",svg_rang) }
-$`'2
+ if "$`'3"=="" then { $`'2 } \
+ else { $`'2 $`'3 - (sind(svg_rang),(cosd(svg_rang)-1))*textht/2 }
command "</g>" } }
define(`svg_rot_')
')
`# svg_rot'_init end
')
+ifelse(0,1,`
+# ifdef(`svg_rot_',,`
+## `svg_rot(degrees,"text" [at position])
+## Rotate text degrees ccw
+## Requires svg_rot_init(filename)
+## which uses both awk and sed.
+## The source must be processed twice by m4 and dpic.'
+# define svg_rot { if retcode != 0 then {$`'2} else {
+# if "$`'1" != "" then { svg_rang = -($`'1) } else { svg_rang = -90 }
+# if svgrot_k != 0 then { svgrot_i +=1
+# command sprintf("<g transform=\"rotate(%g %g %g)\">",svg_rang,\
+# svg_rx[svgrot_i],svg_ry[svgrot_i]) }\
+# else { command sprintf("<g transform=\"rotate(%g)\">",svg_rang) }
+#$`'2
+# command "</g>" } }
+# define(`svg_rot_')
+# ')
+')
+
# ---------------------------------------------------------------------------#
define(`thinlines_',`linethick = 0.4
diff --git a/graphics/circuit_macros/xfig.m4 b/graphics/circuit_macros/xfig.m4
index 04c998eb3c..40fef9bbbe 100644
--- a/graphics/circuit_macros/xfig.m4
+++ b/graphics/circuit_macros/xfig.m4
@@ -1,7 +1,7 @@
divert(-1)
xfig.m4 Initialization for xfig.
-* Circuit_macros Version 9.8, copyright (c) 2022 J. D. Aplevich under *
+* Circuit_macros Version 9.9, copyright (c) 2022 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *