SVG Circuit_macros examples, Version XXX
Home
>
Examples
>
SVG
This file shows diagrams in .svg format produced without the use of
LaTeX or equivalent.
The diagrams have been adapted from the Circuit_macros
examples in order to test the svg output of dpic. Generating svg line
art is straightforward but formatting text is not because TeX, LaTeX,
and related word processors do not produce svg directly. Either
less-sophisticated text formatting must be employed for svg 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.
However, many circuit and similar diagrams intended for the web do not
require sophisticated labels; the examples shown below might
be representative.
Click on the link to view the source of each diagram.
There are other issues:
- 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.
- 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:
-
m4tt`'svg_font(font-face,nominal size[:dptextratio],textoffset,
dpic commands`'m4tt):
Change font face, size, textratio and dpic textoffset parameters.
Change font face and dpic m4tt`'textht, m4tt`'dptextratio,
and m4tt`'textoffset parameters.
If arg4 is blank, the font is changed and
requires m4tt`'command "</g>" to cancel the font change.
Note:
Nominal height = text height in drawing units; actual height =
nominal ht x m4tt`'dptextratio.
Examples:
m4tt`'svg_font(Times)
m4tt`'svg_font(Times,14bp__)
m4tt`'svg_font(sans-serif,14bp__:0.71)
m4tt`'svg_font(Times,11bp__,1bp__,"text" at A)
m4tt`'svg_font(font-family="Times")
m4tt`'svg_font(font-family="Times" font-style="italic")
m4tt`'svg_font(style="font-family:Times; font-style:italic")
- m4tt svgfontratio(font name`'m4tt);
Reasonable m4tt`'dptextratio value for common fonts, used
by m4tt`'svg_font.
- m4tt svg_tspan(text attributes, text`'m4tt);
e.g. m4tt`'svg_tspan(font-style="italic" font-size="75%",XYZ)
- m4tt svg_it(text`'m4tt): for italics
- m4tt svg_tt(text`'m4tt): for monospace (courier)
- m4tt svg_sf(text`'m4tt): sans-serif (Helvetica)
- m4tt svg_norm(text`'m4tt): for normal text
- m4tt svg_bf(text`'m4tt): for bold face
- m4tt svg_small(text, percent`'m4tt):
to set a smaller text size, default 66
- m4tt svg_fsize(text, percent`'m4tt):
for setting larger or smaller text size, default 100
- m4tt svg_sub(text, size percent, y displ, x displ`'m4tt):
subscript
- m4tt svg_ul(text`'m4tt): underlined text
- m4tt svg_ol(text`'m4tt): overlined text
- m4tt svg_sup(text, size percent, y displ, x displ`'m4tt):
superscript
- m4tt svg_hat(character`'m4tt): circumflex-accented character
- m4tt svg_frac(numerator[:wid], denominator[:wid]`'m4tt):
basic fraction, wid in drawing units
- m4tt svg_rot(degrees, "text" [at position]`'m4tt):
Rotate text degrees (default 90) ccw.
Requires m4tt`'svg_rot_init(filename`'m4tt) and the source
must be processed twice.
- m4tt svg_rot_init(filename`'m4tt):
filename is the basename of the output of
m4tt`'dpic -v filename.pic > filename.svg`'m4tt
- m4tt svg_symbol(text`'m4tt): allow quoted pound sign in text,
e.g., m4tt`'svg_symbol(10&`#'176;) produces 10°
- m4tt svgLink(URL, drawing object, m4tt[B]):
link to external file using
<a xlink:href=...>...</a> (default is
m4tt`'target="_blank" unless
arg 3 = B)
- m4tt svgLinkString as above but for strings attached to objects
- Greek and other symbols:
m4tt svg_alpha | changecom(,)&`#'945;changecom(`#')
| m4tt svg_beta | changecom(,)&`#'946;changecom(`#')
| m4tt svg_Gamma | changecom(,)&`#'915;changecom(`#')
| m4tt svg_gamma | changecom(,)&`#'947;changecom(`#')
| m4tt svg_Delta | changecom(,)&`#'916;changecom(`#')
| m4tt svg_delta | changecom(,)&`#'948;changecom(`#')
| m4tt svg_epsilon | changecom(,)&`#'949;changecom(`#')
| m4tt svg_zeta | changecom(,)&`#'950;changecom(`#')
|
m4tt svg_eta | changecom(,)&`#'951;changecom(`#')
| m4tt svg_Theta | changecom(,)&`#'920;changecom(`#')
| m4tt svg_theta | changecom(,)&`#'952;changecom(`#')
| m4tt svg_iota | changecom(,)&`#'953;changecom(`#')
| m4tt svg_kappa | changecom(,)&`#'954;changecom(`#')
| m4tt svg_Lambda | changecom(,)&`#'923;changecom(`#')
| m4tt svg_lambda | changecom(,)&`#'955;changecom(`#')
| m4tt svg_mu | changecom(,)&`#'956;changecom(`#')
|
m4tt svg_nu | changecom(,)&`#'957;changecom(`#')
| m4tt svg_Xi | changecom(,)&`#'926;changecom(`#')
| m4tt svg_xi | changecom(,)&`#'958;changecom(`#')
| m4tt svg_Pi | changecom(,)&`#'928;changecom(`#')
| m4tt svg_pi | changecom(,)&`#'960;changecom(`#')
| m4tt svg_rho | changecom(,)&`#'961;changecom(`#')
| m4tt svg_Sigma | changecom(,)&`#'931;changecom(`#')
| m4tt svg_sigma | changecom(,)&`#'963;changecom(`#')
|
m4tt svg_tau | changecom(,)&`#'964;changecom(`#')
| m4tt svg_upsilon | changecom(,)&`#'965;changecom(`#')
| m4tt svg_Phi | changecom(,)&`#'934;changecom(`#')
| m4tt svg_phi | changecom(,)&`#'966;changecom(`#')
| m4tt svg_chi | changecom(,)&`#'967;changecom(`#')
| m4tt svg_Psi | changecom(,)&`#'936;changecom(`#')
| m4tt svg_psi | changecom(,)&`#'968;changecom(`#')
| m4tt svg_Omega | changecom(,)&`#'937;changecom(`#')
|
m4tt svg_omega | changecom(,)&`#'969;changecom(`#')
| m4tt svg_micro | changecom(,)&`#'956;changecom(`#')
| m4tt svg_ohm | changecom(,)&`#'937;changecom(`#')
| m4tt svg_lt | changecom(,)&`#'60;changecom(`#')
| m4tt svg_gt | changecom(,)&`#'62;changecom(`#')
| m4tt svg_leq | changecom(,)&`#'8804;changecom(`#')
| m4tt svg_geq | changecom(,)&`#'8805;changecom(`#')
| m4tt svg_prime | changecom(,)&`#'8242;changecom(`#')
|
m4tt svg_backsl | changecom(,)&`#'92;changecom(`#')
| m4tt svg_pound | changecom(,)&`#'35;changecom(`#')
| m4tt svg_comma | changecom(,)&`#'44;changecom(`#')
| m4tt svg_lparen | changecom(,)&`#'40;changecom(`#')
| m4tt svg_rparen | changecom(,)&`#'41;changecom(`#')
| m4tt svg_circ | changecom(,)&`#'710;changecom(`#')
| m4tt svg_deg | changecom(,)&`#'176;changecom(`#')
| m4tt svg_grave | changecom(,)&`#'96;changecom(`#')
|
m4tt svg_emsp | |changecom(,)&`#'8195;changecom(`#')|
| m4tt svg_ensp | |changecom(,)&`#'8194;changecom(`#')|
| m4tt svg_thinsp | |changecom(,)&`#'8201;changecom(`#')|
| m4tt svg_equiv | changecom(,)&`#'8801;changecom(`#')
| m4tt svg_tilde | changecom(,)&`#'126;changecom(`#')
| m4tt svg_uscore | changecom(,)&`#'95;changecom(`#')
|
- 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 quickDPV
to go to external
files in new windows. Click on "n-port" in NportDPV to replace the diagram
and then "back" to return.
- Some of the assumptions used to create this draft may be
na&`#'239;ve.
Comments are welcome.
cfig(XXXXX)
|