#!/usr/bin/tclsh set outputFile [lindex $argv 0] set units [lindex $argv 2] set grid [lindex $argv 1] puts "output=$outputFile grid=$grid$units" set gs [open "|gs -sDEVICE=ljet4 -sOutputFile=$outputFile -dNOPAUSE" w] puts $gs \ "%!PS-Adobe-2.0 % there are some -d switches needed for gs to make this work % -dGridSize=number % -dUnits=units (in, mm, pt, pc) /GridSize $grid def /Units {$units} def /Weight {0.1} def gsave initclip clippath pathbbox /PageHeight exch def /PageWidth exch def pop pop grestore /in { 72 mul } def /pt { 1 mul } def /pc { 12 mul } def /mm { 2.8346 mul } def /gridDistance GridSize Units def /nGridsWide PageWidth gridDistance div floor cvi def /nGridsHigh PageHeight gridDistance div floor cvi def /d gridDistance def /dx d 4 div def /dy d 2 div 60 sin mul def /hexPath { dx dy rlineto d 0 rlineto dx dy neg rlineto dx neg dy neg rlineto d neg 0 rlineto dx neg dy rlineto } def /toStart { PageWidth useWide sub 2 div PageHeight useHeight sub 2 div moveto } def Weight setlinewidth toStart 0 1 nGridsHigh { pop 0 1 nGridsWide { pop hexPath exec stroke gridDistance 0 rmoveto } for useWide neg dy 2 mul rmoveto } for showpage quit "