#!/usr/bin/tclsh8.0 proc header {file {gridSize 1} {units pc} {weight 0.1}} { puts $file \ "%!PS-Adobe-2.0 /GridSize $gridSize def /Units {$units} def /Weight {$weight} def " } set gridSize 1 set units pc set weight 0.1 foreach arg $argv { switch -glob $arg { gridSize=* { set gridSize [string range $arg 9 end] } units=* { set units [string range $arg 6 end] } weight=* { set weight [string range $arg 7 end] } default { set filename $arg }}} if [info exists filename] \ { set file [open $filename w] } \ { set file stdout } header $file $gridSize $units $weight puts $file { 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 /useWide gridDistance nGridsWide mul def /useHeight gridDistance nGridsHigh mul def /toStart { PageWidth useWide sub 2 div PageHeight useHeight sub 2 div moveto } def Weight setlinewidth toStart 0 1 nGridsWide { 0 useHeight rlineto gridDistance useHeight neg rmoveto } for stroke toStart 0 1 nGridsHigh { useWide 0 rlineto useWide neg gridDistance rmoveto } for stroke showpage }