#!/usr/local/bin/perl -i # # mutate.p takes a PS file written by gnuplot and modifies it # so that /D is defined to be a smaller diamond # # NB, you can't do multiple files using mutate.p file file file # you have to do a foreach # # but if I undid the preamble thing it would probably still work fine. $shrink="0.5"; # eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $preamble = 1 ; do { $_ = <> ; if ( /\/D\s\{/ ) { print "/hpt5 hpt $shrink mul def\n/vpt5 vpt $shrink mul def\n" ; print "/D { stroke [] 0 setdash 2 copy vpt5 add M\n" ; $_ = <> ; print " hpt5 neg vpt5 neg V hpt5 vpt5 neg V\n" ; $_ = <> ; print " hpt5 vpt5 V hpt5 neg vpt5 V closepath stroke\n" ; $_ = <> ; print " P } def\n" ; $preamble = 0 ; } else { print; } } while ( $preamble ) ; while (<>) { print ; }