#!/usr/bin/perl # Comment: a very rough fig2xcircuit translator # translates only polylines and labels # (was written for converting one file) # Author: Paul Ortyl # License: GPL # Date: 12.02.1999 print <} imagemask} bind {8 8 true tmpa {<30 70 60 02 03 07 06 20>} imagemask} bind {8 8 true tmpa {<0c 1e 1e 0c c0 e1 e1 c0>} imagemask} bind {8 8 true tmpa {<0f 0f 0f 0f f0 f0 f0 f0>} imagemask} bind {8 8 true tmpa {<3f f3 e1 e1 f3 3f 1e 1e>} imagemask} bind {8 8 true tmpa {} imagemask} bind {8 8 true tmpa {} imagemask} bind 7 array astore def /ppaint { gsave clip tmpa dup setmatrix pathbbox neg exch neg 4 2 roll neg 4 -1 roll 2 copy gt {exch} if 8 div ceiling 8 mul 4 2 roll neg 2 copy gt {exch} if 8 div ceiling 8 mul 3 -1 roll -8 5 -1 roll { 3 index exch 5 exch put dup -8 3 index { 3 index exch 4 exch put 3 index exec } for } for pop pop pop pop grestore } bind def /setstyles { currentlinewidth mul setlinewidth /style exch def style 1 and 0 gt not {closepath} if style 2 and 0 gt {currentlinewidth 4 mul dup 2 array astore 0 setdash} if style 4 and 0 gt {0.5 currentlinewidth 4 mul 2 array astore 0 setdash} if style dup 256 ge exch 480 lt and { gsave 1 setgray eofill grestore } if style 16 and 0 gt { gsave style 224 and -5 bitshift dup 7 lt {gar exch get ppaint} { pop eofill } ifelse grestore } if style 8 and 0 gt { newpath } { stroke } ifelse grestore } def /scb { gsave setrgbcolor } bind def /sce { grestore } bind def /polygon { gsave /num exch def moveto num 1 sub {lineto} repeat setstyles } def /xcarc { gsave newpath arc setstyles } def /elb { matrix currentmatrix 7 -1 roll 7 -1 roll translate 5 1 roll 4 -1 roll 3 index div 1 scale } def /ele { 0 4 1 roll 0 4 1 roll } bind def /ellipse { gsave elb newpath ele arc setmatrix setstyles } def /pellip { elb ele arc setmatrix } def /nellip { elb ele arcn setmatrix } def /spline { gsave moveto curveto setstyles } def /polyc { {lineto} repeat } bind def /beginpath { gsave moveto } bind def /endpath { setstyles } bind def /bop { 1 setlinecap 0 setlinejoin 6 setmiterlimit 0 setgray } def /setpagemat {/pagemat matrix currentmatrix def} def /inchscale {setpagemat 0.375 mul dup scale} def /cmscale {setpagemat 0.35433071 mul dup scale} def %%EndResource %%EndProlog % XCircuit output starts here. %%Page: 1 1 %%PageOrientation: Portrait /pgsave save def bop % 0 0 offsets % 40 8 gridspace 1.0000 cmscale 2.6000 setlinewidth EOF $bottom=10000; $line=0; $lastcommand=0; while () { $line+=1; if ($line == 9) { ($resol,$junk)=split(' ',$_,2); $resol*=0.95;} if ( ($line > 9) && /^[0-4]/) { $lastcommand=0; if (/^2 /) {$lastcommand=2; chop; ($oc,$lst,$ls,$lt,$pen_col,$fill_col, $dp,$ps,$af,$sv,$js,$cs,$rad,$fa,$ba,$npo)=split / /,$_; } if (/^4 /) {$lastcommand=0; chop; chop; chop;chop; chop; ($oc,$st,$col,$dep,$pen_sty,$fnt, $fsize,$angle,$flags,$height,$len,$X,$Y,$string)=split / /,$_,14; $x=($X*203.2)/$resol; $y=(($bottom-$Y)*203.2)/$resol; $a=$angle*180/3.1415; printf "(%s) {/Helvetica %.3f cf} 1 17 %.0f %.0f %.0f label\n", $string,$fsize/15, $a, $x , $y ; } } else { if ((/^\t/) && ($lastcommand==2) && ($npo > 1)) { @points=split / /,$_; shift @points; print "1 ",$lt, " "; while($#points >0) { $x=($points[0]*203.2)/$resol; printf "%0.0f ", $x; shift @points; $y=(($bottom-$points[0])*203.2)/$resol; printf "%0.0f ", $y; shift @points; } print $npo, " polygon\n"; } } } print <