- - ## SVG Circuit_macros examples, Version XXX Home > Examples > dpv This file shows a few 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. To generate the equivalent for all the examples, go to the examples/dpv directory and type "make". Typing "make examplesDPVs.html" produces the selection shown here. 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 --pdf and pdf2svg. However, many circuit and similar diagrams intended for the web do not require sophisticated labels; the examples shown below might be representative. Compare them to those in examples.html 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. Diagrams such as these contain text labels that have to be treated differently from the LaTeX-compatible versions; for example, 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 and dpic m4tt`'textht, m4tt`'dptextratio, and m4tt`'textoffset parameters. If arg4 is blank, the font is changed and requires m4tt`'command "</g>" at the end 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 (typically of the form &#nnn; so care is required when used in a macro argument):
    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_amp | changecom(,)&`#'38;changecom(`#') | m4tt svg_emsp | |changecom(,)&`#'8195;changecom(`#')| | m4tt svg_ensp | |changecom(,)&`#'8194;changecom(`#')| | m4tt svg_thinsp | |changecom(,)&`#'8201;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. Some of the assumptions used to create this draft may be na&`#'239;ve. Comments are welcome. ifelse(0,1,`
Fig. m4inx (quickDPV.m4): SVG produced by dpic changecom(,)&`#'8194;changecom(`#') | (quick.m4): SVG produced from quick.pdf by dvisvgm changecom(,)&`#'8194;changecom(`#')
    ',`cfig(quickDPV,
      The quick.m4 example from the manual)
    ')

    ifelse(0,1,`
    cfig(ResistorsDPV,
      Resistors`,' showing some variations and the ebox)

    cfig(CapacitorsDPV,
      Capacitors)

    cfig(InductorsDPV,
      Inductors)

    cfig(DiodesDPV,
      Diodes: appending a m4tt`'K
     to the second argument draws an open
     arrowhead)

    cfig(EmarrowsDPV,
      Radiation arrows)

    cfig(VariableDPV,
      Arrows and marks for showing variability)

    cfig(SourcesDPV,
      Sources and source-like elements)

    cfig(AmpTableDPV,
      Macros m4tt`'amp`,' delay
`,' and m4tt`'integrator) cfig(FusesDPV, Macros m4tt`'fuse`,' m4tt`'cbreaker`,' and m4tt`'jumper) cfig(MoreTableDPV, Additional two-terminal elements) cfig(GroundsDPV, Ground symbols) cfig(SwitchesDPV, The switch macros; m4tt`'switch(`,'`,'`,'L|B|D,attribs) is a wrapper for m4tt`'lswitch`,' m4tt`'bswitch`,' and m4tt`'dswitch
    )

    cfig(AntennasDPV,
      Antenna symbols and the microstrip radial stub)

    cfig(OpampDPV,
      The opamp)

    cfig(AudioDPV,
      Audio elements)

    cfig(XformDPV,
      Some variations of the transformer element`,' drawing direction down)

    cfig(NPDTDPV,
      Double throw with the m4tt`'NPDT
macro) cfig(RotarySwitchDPV, The RotarySwitch macro) cfig(ContactDPV, A non-exhaustive sampling of m4tt`'contact macro variations) cfig(ContactsDPV, The m4tt`'contacts macro) cfig(relaycoilDPV, The m4tt`'relaycoil macro) cfig(RelayDPV, Some variants of m4tt`'relay) cfig(JackDPV, The m4tt`'jack and m4tt`'plug macros) cfig(TstripDPV, The m4tt`'tstrip`,' ccoax`,' and m4tt`'tbox macros) cfig(ConnDPV, The tconn and m4tt`'Pconn macros) cfig(PconnDPV, The m4tt`'pconnex
     macro)

    cfig(cbresistorDPV,
      Color-coded through-hole resistors)

    cfig(EVplugsDPV,
      Electric vehicle charging plug patterns make extensive
          use of key=value pairs to set options)

    cfig(HeadersDPV,
      The m4tt`'Header
     macro)

    ')
    cfig(SocketsDPV,
      Some connectors with simple geometry
      and lists of labels)

    ifelse(0,1,`
    cfig(ChipsDPV,
      IC outlines)

    cfig(fetDPV,
      FETs`,' showing programmable components and example customizations)

    cfig(ujtDPV,
      UJT examples)

    cfig(ThyristorDPV,
      Thyristor examples. The thyristor is a 3- or 4-terminal
        composite element)

    cfig(BipDPV,
      Bipolar transistors (drawing direction: up))

    cfig(TgateDPV,
      The m4tt`'tgate
and m4tt`'ptrans elements) ') cfig(NportDPV, The m4tt`'nport and m4tt`'nterm macros) ifelse(0,1,` cfig(NLGDPV, Some customizations of m4tt`'nport) cfig(WindingsDPV, The macros m4tt`'winding(L|R`,'diam`,'pitch`,'turns`,'core wid`,'"core color") and m4tt`'arcwinding(diam`,'pitch`,'turns`,'core wid`,'"core color")
    )

    ')
    cfig(ex01DPV,
      Two simple labeled circuits)

    ifelse(0,1,`
    cfig(ex02DPV,
      Elements at obtuse angles)

    cfig(OptoisoDPV,
      Optical isolator: a circuit with right or left orientation)

    cfig(MixerDPV,
      A balanced mixer`,' using m4tt`'mosfet
     and a custom transformer)

    cfig(PushPullDPV,
      A push-pull mixer`,' showing FETs with multiple gates)

    cfig(QuantumDPV,
      Quantum circuits)

    cfig(SixpoleDPV,
      A six-pole filter)

    cfig(ex18DPV,
      Precision half-wave rectifier and a tunnel diode circuit
         (illustrating m4tt`'opamp`,' diode`,' resistor`,' ground`,'
and labels)) cfig(ex10DPV, Non-planar graph and bistable circuit (illustrating the m4tt`'crossover
     macro and colored elements))

    cfig(ThreeDPV,
      Three-phase oscillator)

    cfig(MCDPV,
      A three-phase switched AC-AC converter and a DC-DC converter)

    cfig(ex12DPV,
       A CMOS NAND gate`,' a test circuit`,' and an XMOSFET example)

    cfig(pwrsupplyDPV,
      An elementary power supply circuit with colored elements`,'
          and a multiple-winding transformer with 3-phase rectifier)

    cfig(TTLnandDPV,
       TTL NAND gate illustrating a transistor with multiple emitters)

    cfig(I2LDPV,
       Gate circuit and equivalent embedded components
          illustrating multiple collectors)

    cfig(SchottkyDPV,
       A 4-input NAND circuit illustrating the m4tt`'S
(Schottky) option of m4tt`'bi_trans
    )

    cfig(ex11DPV,
      Transistor radio audio chain)

    cfig(ex04DPV,
      Labels on non-manhattan elements)

    ')
    cfig(CsourceDPV,
      Realization of a controlled source
            (illustrating stacked element labels))

    cfig(AudioAmpDPV,
      A 50 W audio amplifier)

    ifelse(0,1,`
    cfig(DriveDPV,
      Synchronous machine driven by variable-speed drive and rectifier)

    cfig(ex16DPV,
      A rate 1/2 binary convolutional coder and its state diagram)

    cfig(ex03DPV,
      Digital filter)

    cfig(LadderDPV,
      Ladder-logic elements)

    cfig(MotorControlDPV,
      Motor control connections)

    cfig(RectifiersDPV,
      Rectifier circuits and waveforms)

    ')
    cfig(HeathkitDPV,
      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)

    ifelse(0,1,`
    cfig(lcctDPV,
      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)

    cfig(TubediagsDPV,
      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)

    cfig(UNODPV,
      An Arduino UNO circuit adapted and redrawn)

    cfig(sfgDPV,
      Signal-flow graphs)

    cfig(LogicDPV,
      Basic logic gates)

    cfig(ex08DPV,
      General-purpose latch: a small logic circuit)

    cfig(DecoderDPV,
      Decoder logic`,' constructed using the m4tt`'for_
     macro)

    cfig(ex21DPV,
      Some flip-flops)

    cfig(MultiplexerDPV,
      Multiplexer)

    cfig(DemultiplexerDPV,
      Demultiplexer)

    cfig(ShiftRDPV,
      A 5-bit shift register drawn using a custom flip-flop)

    cfig(AdderDPV,
      A full adder and a cascade of n-bit adders)

    cfig(CanLogicDPV,
      A way of automatically drawing two-layer logic diagrams)

    cfig(AlogixDPV,
      The m4tt`'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.) cfig(ABlogixDPV, The m4tt`'Autologix macro can draw inputs on the left but the added drawing complexity may require hand tuning with second-argument options: m4tt`'L puts the inputs on the left`,' m4tt`'R reverses their order`,' m4tt`'V scans the input arguments in reverse order`,' and m4tt`'offset=`'value displaces the array of inputs) cfig(XORDPV, Realizations of the XOR function using m4tt`'Autologix
    )

    ')
    cfig(EEPDPV,
      Part of a single-line diagram of a power distribution system
      using draft elements)

    cfig(MechanicsDPV,
        Some basic mechanical components and an example containing a custom string)

    ifelse(0,1,`
    cfig(ex05DPV,
      Use of m4tt`'darrow
and m4tt`'Darc
    )

    cfig(GrayCodeDPV,
      Gray code 10-bit encoder disk pattern`,'
      and a crossbar switch)

    ')
    cfig(controlDPV,
      Control-system block diagrams)

    cfig(ByteDPV,
      Elementary splines)

    cfig(SevensegmentDPV,
      A customizable seven-segment display showing the numbered segments with
      a custom shape and the numerals from 0 to 9)

    ifelse(0,1,`
    cfig(RotboxDPV,
      The macro
         m4tt`'rotbox(
wid,ht,type,[r|t=val])
         draws a box in the current direction)

    cfig(ex06DPV,
      Crosshatching)

    cfig(GeometryDPV,
      Plane geometry examples)

    cfig(LoglogDPV,
      Graphs drawn using the pic language)

    cfig(SmithchartDPV,
      A Smith chart)

    cfig(ex09DPV,
      Illustrating the macro
          m4tt`'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 m4tt`'" or m4tt`'sprintf is copied literally. If label is an m4tt`'s_box(...) then setting argument 4 to m4tt`'H`,' m4tt`'W`,' or m4tt`'D tailors the blank width to the m4tt`'s_box height`,' width`,' or diagonal respectively; i.e.`,' m4tt`'W is equivalent to m4tt`'s_wd+textoffset*2. The macro m4tt`'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.) cfig(PlateDPV, Dimensioning with tolerances according to ASME Y14.5) Use of m4tt`'darrow and m4tt`'Darc) cfig(randomDPV, Testing random number generation using dpic macro m4tt`'randn(array name`,' mean`,' std devm4tt`') which calls dpic built-in m4tt`'rand()) cfig(expDPV, Test of m4tt`'project and other m4tt`'lib3D macros`,' showing the projection of a solid onto the y1`,'z1 plane by sighting along the x1 axis.) cfig(graysurfDPV, Plotting surfaces using gray scales) cfig(shapesDPV, Basic shapes) cfig(cscDPV, Conestoga Sailing Club (illustrating the filling of arbitrary shapes)`,' and an antique clock face with shading and rotated text) cfig(roseDPV, A window redrawn from a detail of the set design for the musical Dracula`,' used for testing m4tt`'dpic`,' and an experimental halftone. This diagram consumes much LaTeX main memory but can be produced directly as pdf using m4tt`'dpic -d`,' as svg using m4tt`'dpic -v`,' or as postscript using m4tt`'dpic -r since no text formatting is required) cfig(diamondDPV, Variations on M. Goossens`,' S. Rahtz`,' and F. Mittelbach`,' The LaTeX Graphics Companion
    `,' Addison-Wesley 1997`,' pp. 57-58)

    cfig(wormDPV,
      An exercise in calculating RGB colours)

    cfig(ButtonsDPV,
      Shading in color)

    cfig(keyboardDPV,
      More objects drawn in relief)

    cfig(DiniDPV,
      Dini surface`,' an icosahedron`,' and a sphere with inscribed cylinder)

    cfig(SierpinskiDPV,
      The Sierpinski triangle and a Cayley graph:
        tests of pic macro recursion)

    cfig(EscherDPV,
      Penrose stairs and an Escher-like object)

    cfig(recycleDPV,
      Modest repetition and partial fill)

    cfig(ex15DPV,
      Simple diagrams that are easily drawn by looping)

    cfig(CrowDPV,
      Illustrating m4tt`'shadebox
     and a custom crowfoot line
     termination)

    ')
    cfig(FlowDPV,
      A flowchart sampler)

    ifelse(0,1,`
    cfig(BtreeDPV,
      Trees)

    cfig(InclepsDPV,
      Overlaying a figure with line graphics,,OBJECT)
    ')

    cfig(paletteDPV,
      A draft palette of a few elements for Inkscape using
      a 1 mm grid)

    cfig(FontsDPV,
      Available fonts)