This file shows diagrams in .svg format;
png
versions are also available.
The PDF equivalent can be found in examples.pdf of the distribution.
The diagrams shown below have been adapted from the Circuit_macros
examples in order to test the svg output of dpic. Generating svg line
art is straightforward, but TeX, LaTeX, and related word
processors do not produce svg. Either less-sophisticated text formatting
must be employed or an
intermediate format
such as pdf can be
produced, followed by an additional processing step to convert to svg.
Two possibilities for the latter are
dvisvgm
and
pdf2svg although
there may be font-related issues for some diagrams.
Many circuit and similar diagrams intended for the web do not
require sophisticated labels, however; the examples shown below might
be representative.
Click on the link to view the source of each diagram.
There are a number of other issues:
Embedding .svg files in html documents with the <embed> or
<object> tag seems to be a perennial issue.
This file has been tested mainly by using Firefox.
The Adobe reader apparently requires a line of the form
<embed src="figure.svg" width="x" height="y" type="image/svg+xml"
/>
This means that the html file has to contain dimension
information for each figure, whereas Firefox can
determine the figure size
from the <svg ... object. Currently, dpic includes a comment line
giving reasonable dimensions in pixels but this has to be insterted into
the <embed or <object line. A makefile does it easily but
otherwise this could be tedious.
The default font face is not specified in all of these diagrams but is
inherited from the enclosing document, so the appearance of labels can
differ depending on the browser. Some of these diagrams set the font at
the beginning of the diagram source.
The <svg tag may require modification
from the default used for this test. Dpic might be modified to
allow the generation of custom headers but that has not been done.
Diagrams such as these contain text labels
that have to be treated differently from the LaTeX-compatible versions.
Apparently there is no direct way to know the bounding box of arbitrary svg
text.
Consequently, text placement is approximate and may require
manual adjustment.
Rather than patch the original source files for svg production, edited copies
have been used. The configuration file svg.m4 read by m4
prior to libcct.m4 contains the following macros defined for svg.
Others could be defined to exercise some of the media capabilties of svg.
They are subject to change:
svg_font(font-face,nominal size[:dptextratio],textoffset,
dpic commands):
Change font face, size, textratio and dpic textoffset parameters.
Change font face and dpic textht, dptextratio,
and textoffset parameters.
If arg4 is blank, the font is changed and
requires command "</g>" to cancel the font change.
Note:
Nominal height = text height in drawing units; actual height =
nominal ht x dptextratio.
Examples: svg_font(Times) svg_font(Times,14bp__) svg_font(sans-serif,14bp__:0.71) svg_font(Times,11bp__,1bp__,"text" at A) svg_font(font-family="Times") svg_font(font-family="Times" font-style="italic") svg_font(style="font-family:Times; font-style:italic")
svgfontratio(font name);
Reasonable dptextratio value for common fonts, used
by svg_font.
svg_tspan(text attributes, text);
e.g. svg_tspan(font-style="italic" font-size="75%",XYZ)
svg_it(text): for italics
svg_tt(text): for monospace (courier)
svg_norm(text): for normal text
svg_bf(text): for bold face
svg_small(text, percent):
to set a smaller text size, default 66
svg_fsize(text, percent):
for setting larger or smaller text size, default 100
svg_sub(text, size percent, y displ, x displ):
subscript
svg_sup(text, size percent, y displ, x displ):
superscript
svg_rot(degrees, "text" [at position]):
Rotate text degrees (default 90) ccw.
Requires svg_rot_init(filename) and the source
must be processed twice.
svg_rot_init(filename):
filename is the basename of the output of
dpic -v filename.pic > filename.svg
svgLink(URL, drawing object, [B]):
link to external file using
<a xlink:href=...>...</a> (default is
target="_blank" unless
arg 3 = B)
svgLinkString as above but for strings attached to objects
Greek and other symbols:
svg_alpha
α
svg_beta
β
svg_Gamma
Γ
svg_gamma
γ
svg_Delta
Δ
svg_delta
δ
svg_epsilon
ε
svg_zeta
ζ
svg_eta
η
svg_Theta
Θ
svg_theta
θ
svg_iota
ι
svg_kappa
κ
svg_Lambda
Λ
svg_lambda
λ
svg_mu
μ
svg_nu
ν
svg_Xi
Ξ
svg_xi
ξ
svg_Pi
Π
svg_pi
π
svg_rho
ρ
svg_Sigma
Σ
svg_sigma
σ
svg_tau
τ
svg_upsilon
υ
svg_Phi
Φ
svg_phi
φ
svg_chi
χ
svg_Psi
Ψ
svg_psi
ψ
svg_Omega
Ω
svg_omega
ω
svg_micro
μ
svg_ohm
Ω
svg_lt
<
svg_gt
>
svg_leq
≤
svg_geq
≥
svg_prime
′
svg_backsl
\
svg_pound
#
svg_comma
,
svg_lparen
(
svg_rparen
)
svg_circ
ˆ
svg_deg
°
svg_emsp
| |
svg_ensp
| |
svg_thinsp
| |
Inkscape: It may be efficient to define elements by macro and to
place them using a wysiwyg graphics editor. A draft page intended
for Inkscape is included. A reasonable variety of elements is defined
but many more could be added and they should be customized for
particular applications. Adjustments may also have to be made to
obtain the proper snap-to actions.
Link experiments: Click on the resistor or source of quickSVG
to go to external
files in new windows. Click on "n-port" in NportSVG to replace the diagram
and then "back" to return.
Some of the assumptions used to create this draft may be
naïve.
Comments are welcome.
HeathkitSVG.m4:
The power supply of a Heathkit AR-15 (Now, that
was a receiver!) with custom transformer and other elements,
drawn on a grid (partially shown) to aid in placement
lcctSVG.m4:
A digital circuit of moderate size,
redrawn from M. P. Maclenan and G. M. Burns,
"An Approach to Drawing Circuit Diagrams for Text Books,"
Tugboat (12)1, March 1991, pp. 66-69
UNOSVG.m4:
An Arduino UNO circuit adapted and redrawn
TubediagsSVG.m4:
Electron-tube diagrams: a few bottom-view base diagrams,
a generic triode test circuit, and a 25-watt audio amplifier adapted
from F. Langford-Smith, Radiotron Designers Handbook, fourth
edition, Harrison, NJ: Radio Corporation of America, 1952
ShiftRSVG.m4:
A 5-bit shift register drawn using a custom flip-flop
AdderSVG.m4:
A full adder and a cascade of n-bit adders
CanLogicSVG.m4:
A way of automatically drawing two-layer logic diagrams
AlogixSVG.m4:
The Autologix(Boolean expression;
Boolean expression... , options)
macro automatically draws Boolean expressions in function notation.
The function tree is drawn, then a row or column of inputs, then
the connections. The default result is on the left,
a custom element at the top, and a tree of gates only is shown
on the right. THe lower examples illustrate the L, R, and V options.
ABlogixSVG.m4:
The Autologix macro can draw inputs on the left but
the added drawing complexity may require hand tuning with
second-argument options: L puts the inputs on the left,
R reverses their order, V scans the input arguments
in reverse order, and offset=value displaces
the array of inputs
XORSVG.m4:
Realizations of the XOR function using Autologix
paletteSVG.m4:
A draft palette of a few elements for Inkscape using
a 1 mm grid
ex09SVG.m4:
Illustrating the macro
dimension_(linespec, offset, label,
H|W|D|blank width, tic offset, <-|->).
A negative second argument implies an offset to the right of the
linespec direction. A label starting with
" or
sprintf is copied literally. If label is an
s_box(...) then setting argument 4 to H,
W,
or D tailors the blank width to the s_box height,
width, or diagonal respectively; i.e., W is equivalent to
s_wd+textoffset*2.
The macro arcdimension_ is similar but the first argument
specifies the arc to be dimensioned and the second argument is
the outward radial offset of the dimension arrow arc.
Y14-5SVG.m4:
Dimensioning with tolerances according to ASME Y14.5
cscSVG.m4:
Conestoga Sailing Club (illustrating the filling of arbitrary
shapes)
roseSVG.m4:
Redrawn from a detail of the set design for the musical
Dracula, used for testing dpic. This diagram
consumes much LaTeX main memory but can be produced
directly as pdf using dpic -d,
as svg using dpic -g,
or as postscript using dpic -r
since no text formatting is required
diamondSVG.m4:
Variations on M. Goossens, S. Rahtz, and F. Mittelbach,
The LaTeX Graphics Companion, Addison-Wesley 1997, pp. 57-58
wormSVG.m4:
An exercise in calculating RGB colours