Wikipedia:How to draw SVG circuits using Xcircuit

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Negative impedance converter drawn with Xcircuit
This how-to is Linux-based. If you can do it for any other OS, please improve it
Obsolete - Inkscape can import Postscript directly (using pstoedit for the conversion) and pstoedit can convert from Postscript directly to svg using the plot-svg output filter.

Xcircuit cannot export in SVG straight away, but the format it uses to save data (PostScript) is a vectorial format, so it can be converted to SVG. These are the steps I followed to create the picture on the right.

  • Create the circuit with Xcircuit without any text (we'll add it later). Then go to File -> Write Xcircuit PS. In the window that comes up, write the name of the file in the Filename box and click on Apply, than change the scale from 1.00000 to 5.00000 and click on Apply again. I have chosen 5 after several tests, but I think it would be better to make all the circuits with this scale, in order to get a uniform output.
  • now we have a filename.ps and we want to convert it to SVG. Working under Linux, here is a small Bash script that will do everything by itself. Open any text editor and put the following code into it:
#!/bin/bash

# you need gs-common, pstoedit and skencil to
# get this script working
export BASENAME="`basename $1`";

# Outline fonts
eps2eps -dNOCACHE ${BASENAME}.ps ${BASENAME}2.ps

# Fix bounding box
ps2epsi  ${BASENAME}2.ps  ${BASENAME}.ps
rm ${BASENAME}2.ps

# Convert to Sketch
pstoedit -f sk  ${BASENAME}.ps  ${BASENAME}.sk

# Convert to SVG
skconvert  ${BASENAME}.sk  ${BASENAME}.svg

save it with the name ps2svg.sh and make it executable running the following command on the terminal:

chmod a+x ps2svg.sh

Check if you have all the necessary programs. In particular you will need Sketch; if you use Debian/Ubuntu, there is everything in the standard repositories.

Now you can run:

./ps2svg.sh filename

and you will get a nice filename.svg in the same directory. Now open the new file with Inkscape to add the text. For the text in the picture on the top, I used font family Serif (you can choose it, whichever OS you are working on), font weight Bold, size 72px. Then I made the subscripts smaller, using the same font style, changing only the size to 56px. Optionally you can actually move the subscripts downwards pressing Alt+down, but sometimes it is not rendered properly by Wikipedia.

As of July 2009, Xcircuit can output a single page directly as a .svg file. Starting with version 3.6.156, choose File->Export->SVG from the menu. This will generate an output file of the same name as the page label with the extension '.svg'. You can also use the console to type "svg filename" to generate the SVG output. The SVG format uses the subset of the format that is implemented in the Mozilla Firefox browser. Because the SVG format does not allow in-line raster images, all raster graphics are dumped to separate files in PNG format (this only works if the ImageMagick convert tool is available on the system).


See also[edit]