#!/usr/bin/perl # Pass a file name for a board to be processed. # EPS is output to draw the component placement diagram. $prolog = <<'!POSTSCRIPT!'; %!PS % Assume the page is 11x17 inches, and the resolution is 72/inch. % Reserve a half inch border all around, making a print % area of 10x16. /inch { 72 mul } def /midy { 10 2 div inch } def /midx { 16 2 div inch } def << /PageSize [17 inch 11 inch] >> setpagedevice /Courier findfont 8 scalefont setfont % Procedure to center text /ct { % Pass text on stack gsave moveto rotate dup stringwidth pop 2 div dup 0 exch sub 0 translate exch show 0 translate grestore } bind def % Coordinate transfer: /inch { 72 mul } def /EU { 25.4 div inch } def % Linestyle: 1 setlinecap 1 setlinejoin % Drawing functions: /l { % draw a line /lw exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def newpath x1 EU y1 EU moveto x2 EU y2 EU lineto lw EU setlinewidth stroke } def /h { % draw a hole /d exch def /y exch def /x exch def d 0 gt { newpath x EU y EU d 2 div EU 0 360 arc currentgray dup 1 exch sub setgray fill setgray } if } def /b { % draw a bar /an exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch def /w2 x2 x1 sub 2 div EU def /h2 y2 y1 sub 2 div EU def gsave x1 x2 add 2 div EU y1 y2 add 2 div EU translate an rotate newpath w2 h2 moveto w2 neg h2 lineto w2 neg h2 neg lineto w2 h2 neg lineto closepath fill grestore } def /c { % draw a circle /lw exch def /rd exch def /y exch def /x exch def newpath lw EU setlinewidth x EU y EU rd EU 0 360 arc stroke } def /a { % draw an arc /lc exch def /ae exch def /as exch def /lw exch def /rd exch def /y exch def /x exch def lw rd 2 mul gt { /rd rd lw 2 div add 2 div def /lw rd 2 mul def } if currentlinecap currentlinejoin lc setlinecap 0 setlinejoin newpath lw EU setlinewidth x EU y EU rd EU as ae arc stroke setlinejoin setlinecap } def /p { % draw a pie /d exch def /y exch def /x exch def newpath x EU y EU d 2 div EU 0 360 arc fill } def /edge { 0.20710678119 mul } def /o { % draw an octagon /an exch def /dy exch def /dx exch def /y exch def /x exch def gsave x EU y EU translate an dx dy lt { 90 add /dx dy /dy dx def def } if rotate newpath 0 dx 2 div sub EU 0 dy edge add EU moveto 0 dx dy sub 2 div sub dy edge sub EU 0 dy 2 div add EU lineto 0 dx dy sub 2 div add dy edge add EU 0 dy 2 div add EU lineto 0 dx 2 div add EU 0 dy edge add EU lineto 0 dx 2 div add EU 0 dy edge sub EU lineto 0 dx dy sub 2 div add dy edge add EU 0 dy 2 div sub EU lineto 0 dx dy sub 2 div sub dy edge sub EU 0 dy 2 div sub EU lineto 0 dx 2 div sub EU 0 dy edge sub EU lineto closepath fill grestore } def !POSTSCRIPT! open(INPUT, $ARGV[0]) || die "$ARGV[0]: $!"; $of = $ARGV[0]; die "usage: $0 .brd\n" unless $of =~ s/.brd$//; $of .= ".cp.eps"; open(OUTPUT, ">$of") || die "$of: $!"; print OUTPUT $prolog; $board = 0; # Convert input units (mm) to output units (1/72 inches) sub mm { local($m) = @_; return $m; $m *= 7200; $m = $m * 72 / 25.4; # mm to units return int($m * 1000 + 0.5) / 1000; } $geometry = ""; while () { $board = 1 if //; next unless $board; if (//) { $package = ""; } elsif (/