diff --git a/gerber/prettygerbv b/gerber/prettygerbv new file mode 100755 index 0000000..9cbfcac --- /dev/null +++ b/gerber/prettygerbv @@ -0,0 +1,111 @@ +#!/bin/sh +# +# prettygerbv - Use gerbv to generate "pretty" views of a PCB +# +# Written 2011 by Werner Almesberger +# Copyright 2011 Werner Almesberger +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + + +COPPER="(cons 'color #(65535 50401 10000))" +PASTE="(cons 'color #(39083 39083 50000))" +MASK="(cons 'inverted #t) (cons 'color #(8839 53994 8178))" +SILK="(cons 'color #(65535 65535 65535))" +EDGE="(cons 'color #(0 0 0))" + +FRONT="(cons 'color #(65535 10000 10000))" +BACK="(cons 'color #(30000 65535 30000))" +EDGE2="(cons 'color #(30000 40000 65535))" + + +usage() +{ + cat <&2 +usage: $0 project-name view png-file + + view "front", "back", "conn", "all" +EOF + exit 1 +} + + +run_gerbv() +{ + gerbv -p _gvp --dpi=600 -x png -o "$1" +} + + +front() +{ + cat <_gvp +(gerbv-file-version! "2.0A") +(define-layer! 4 (cons 'filename "$NAME-Front.gtl") $COPPER) +(define-layer! 3 (cons 'filename "$NAME-SoldP_Front.gtp") $PASTE) +(define-layer! 2 (cons 'filename "$NAME-Mask_Front.gts") $INV $MASK) +(define-layer! 1 (cons 'filename "$NAME-SilkS_Front.gto") $SILK) +(define-layer! 0 (cons 'filename "$NAME-PCB_Edges.gbr") $EDGE) +(set-render-type! 2) +EOF + run_gerbv "$1" +} + + +back() +{ + cat <_gvp +(gerbv-file-version! "2.0A") +(define-layer! 4 (cons 'filename "$NAME-Back.gbl") $COPPER) +(define-layer! 3 (cons 'filename "$NAME-SoldP_Back.gbp") $PASTE) +(define-layer! 2 (cons 'filename "$NAME-Mask_Back.gbs") $INV $MASK) +(define-layer! 1 (cons 'filename "$NAME-SilkS_Back.gbo") $SILK) +(define-layer! 0 (cons 'filename "$NAME-PCB_Edges.gbr") $EDGE) +(set-render-type! 2) +EOF + run_gerbv _tmp.png + convert -flop _tmp.png "$1" + rm -f _tmp.png +} + + +conn() +{ + cat <_gvp +(gerbv-file-version! "2.0A") +(define-layer! 2 (cons 'filename "$NAME-Back.gbl") $BACK) +(define-layer! 1 (cons 'filename "$NAME-Front.gtl") $FRONT) +(define-layer! 0 (cons 'filename "$NAME-PCB_Edges.gbr") $EDGE2) +(set-render-type! 2) +EOF + run_gerbv "$1" +} + + +all() +{ + front _front.png + back _back.png + conn _conn.png + montage -geometry +4+4 _front.png _back.png _conn.png "$1" + rm -f _front.png _back.png _conn.png +} + +[ "$4" ] && usage +[ ! "$3" ] && usage + +NAME=$1 +OUT=$3 + +case "$2" in + front|back|conn) ;; + all) ;; + *) usage;; +esac + +$2 "$OUT" + +rm -f _gvp