SVG Circuit_macros examples, Version 9.3.1

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 relatively 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.
      svg_font(Times,11bp__,1bp__,"text" at A)
      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
    • svg_symbol(text): allow quoted pound sign in text, e.g., svg_symbol(10&`#'176;) produces 10°
    • 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_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.
  • 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.

SVG produced by dpic:   quickSVG.m4

SVG produced from quick.pdf by dvisvgm:   quick.m4

Two-terminal elements:   CctTableSVG.m4

Diodes: a K in the second argument draws an open arrowhead:   DiodesSVG.m4

Radiation arrows:   EmarrowsSVG.m4

Sources and source-like elements:   SourcesSVG.m4

Arrows and marks indicating variability:   VariableSVG.m4

Macros amp, delay, and integrator:   AmpTableSVG.m4

Macros fuse and cbreaker:   FusesSVG.m4

The switch macros; switch(,,,L|B|D) is a wrapper for lswitch, bswitch, and dswitch:   SwitchesSVG.m4

Ground symbols:   GroundsSVG.m4

Antenna symbols:   AntennasSVG.m4

Audio elements:   AudioSVG.m4

The opamp:   OpampSVG.m4

The transformer element, drawing direction down:   XformSVG.m4

Double throw with the NPDT macro:   NPDTSVG.m4

A non-exhaustive sampling of contact macro variations:   ContactSVG.m4

The contacts macro:   ContactsSVG.m4

The relaycoil macro:   relaycoilSVG.m4

Some variants of the relay macro:   RelaySVG.m4

The jack and plug macros:   JackSVG.m4

The tstrip, ccoax, tconn, and tbox macros:   ConnSVG.m4

The pconnex macro:   PconnSVG.m4

The Header macro:   HeadersSVG.m4

Some connectors with simple geometry and lists of labels:   ConnectorsSVG.m4

FETs, showing programmable components and example customizations:   fetSVG.m4

UJT examples:   ujtSVG.m4

Thyristor examples:   thyristorSVG.m4

Bipolar transistors (drawing direction: up):   BipSVG.m4

The tgate and ptrans elements:   TgateSVG.m4

The nport and nterm macros:   NportSVG.m4

Some customizations of nport:   NLGSVG.m4

The macro winding(L|R,diam,pitch,turns,core wid,core color):   WindingsSVG.m4


Two simple labeled circuits:   ex01SVG.m4

Elements at obtuse angles:   ex02SVG.m4

Optical isolator: a circuit with right or left orientation:   OptoisoSVG.m4

A balanced mixer, using mosfet and a custom transformer:   MixerSVG.m4

A push-pull mixer, showing FETs with multiple gates:   PushPullSVG.m4

A quantum circuit:   QuantumSVG.m4

Superconducting quantum interface device (drawing direction down):   SQUIDSVG.m4

A six-pole filter:   SixpoleSVG.m4

Precision half-wave rectifier and a tunnel diode circuit (illustrating opamp, diode, resistor, ground, and labels):   ex18SVG.m4

A three-phase switched AC-AC converter and a DC-DC converter:   MCSVG.m4

Non-planar graph and bistable circuit (illustrating the crossover macro and colored elements):   ex10SVG.m4

Three-phase oscillator:   ThreeSVG.m4

A repetitive network created by Pic looping and a skewed circuit used to test the macro parallel_:   ex17SVG.m4

A CMOS NAND gate, a test circuit, and an XMOSFET example:   ex12SVG.m4

An elementary power supply circuit with colored elements, and a multiple-winding transformer with 3-phase rectifier:   pwrsupplySVG.m4

TTL NAND gate illustrating a transistor with multiple emitters:   TTLnandSVG.m4

Gate circuit and equivalent embedded components illustrating multiple collectors:   I2LSVG.m4

A 4-input NAND circuit illustrating the S (Schottky) option of bi_trans:   SchottkySVG.m4

Transistor radio audio chain:   ex11SVG.m4

Labels on non-manhattan elements:   ex04SVG.m4

Realization of a controlled source (illustrating stacked element labels):   CsourceSVG.m4

Synchronous machine driven by variable-speed drive and rectifier:   DriveSVG.m4

A rate 1/2 binary convolutional coder and its state diagram:   ex16SVG.m4

Digital filter:   ex03SVG.m4

Motor control connections:   MotorControlSVG.m4

Rectifier circuits and waveforms:   RectifiersSVG.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:   HeathkitSVG.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:   lcctSVG.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:   TubediagsSVG.m4

Signal-flow graphs:   sfgSVG.m4

Basic logic gates:   LogicSVG.m4

General-purpose latch: a small logic circuit:   ex08SVG.m4

Decoder logic, constructed using the for_ macro:   DecoderSVG.m4

Some flip-flops:   ex21SVG.m4

Multiplexer:   MultiplexerSVG.m4

Demultiplexer:   DemultiplexerSVG.m4

A 5-bit shift register drawn using a custom flip-flop:   ShiftRSVG.m4

A full adder and a cascade of n-bit adders:   AdderSVG.m4

A way of automatically drawing two-layer logic diagrams:   CanLogicSVG.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.:   AlogixSVG.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:   ABlogixSVG.m4

reverses their order, V scans the input arguments in reverse order, and offset=value displaces the array of inputs)

Realizations of the XOR function using Autologix:   XORSVG.m4

A draft palette of a few elements for Inkscape using a 1 mm grid:   paletteSVG.m4

Line diagrams:   ex00SVG.m4

Control-system block diagrams that do not require m4:   controlSVG.m4

Gray code 10-bit encoder disk pattern:   GrayCodeSVG.m4

A crossbar switch:   CrossbarSVG.m4

Elementary splines:   ByteSVG.m4

The macro rotbox(wid,ht,type,[r|t=val]) draws a box in the current direction:   RotboxSVG.m4

Crosshatching by for loops:   ex06SVG.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.:   ex09SVG.m4

Use of darrow:   ex05SVG.m4

A graph drawn using the pic language:   LoglogSVG.m4

Testing random numbers:   randomSVG.m4

Test of project and other lib3D macros, showing the projection of a solid onto the y1,z1 plane by sighting along the x1 axis.:   expSVG.m4

Plotting surfaces using gray scales. A sort algorithm determines plotting order:   graysurfSVG.m4

Basic shapes:   shapesSVG.m4

An antique clock face:   AntiqueClockSVG.m4

Illustrating a Lyapunov function:   LyapSVG.m4

Conestoga Sailing Club (illustrating the filling of arbitrary shapes):   cscSVG.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:   roseSVG.m4

Variations on M. Goossens, S. Rahtz, and F. Mittelbach, The LaTeX Graphics Companion, Addison-Wesley 1997, pp. 57-58:   diamondSVG.m4

An exercise in calculating RGB colours:   wormSVG.m4

Shading in color:   ButtonsSVG.m4

Dini surface and an icosahedron:   DiniSVG.m4

The Sierpinski triangle and a Cayley graph: tests of pic macro recursion:   SierpinskiSVG.m4

Modest repetition and partial fill:   recycleSVG.m4

Simple diagrams that are easily drawn by looping:   ex15SVG.m4

An example of enumeration:   CountingSVG.m4

Illustrating shadebox and a custom crowfoot line termination:   CrowSVG.m4

A flowchart sampler:   FlowSVG.m4

A binary tree:   BtreeSVG.m4

Another tree:   TtreeSVG.m4

Overlaying a figure with line graphics:   InclepsSVG.m4