#!/usr/bin/perl

while (<>) {
	$line = $_;
	$line =~ s/setgray/1 sub abs setgray/;
	print $line;
	if ($line =~ /^\%\%Page:/) {
		print '% Iain\'s color inversion hack
0 setgray
newpath
0 0 moveto
900 0 lineto
900 900 lineto
0 900 lineto
closepath
fill
1 setgray
% end Iain\'s color inversion hack
'
	}
}

# {{{ Begin POD
=pod

=head1 NAME

psinvert - creates a black on white version of a postscript file

=head1 SYNOPSIS

psinvert input.ps > output.ps

=head1 DESCRIPTION

I find white text on a black background much easier to read on screen than black
on white; especially when I have a monitor with a low refresh rate. This script
attempts to make the document white on black.

This is a quick hack that draws a black box whenever it sees a %%PAGE DSC
comment and then sets the pen color to white. It also tries to invert the
argument of any setgray call.

=head1 BUGS

Many.

Basically this will only work with very simple postscript documents that do not
do anything with colors themselves other than call setgray.

If the word setgray appears in the text of a document it will have "1 sub abs "
prepended to it.

The source document must have DSC page comments.

=head1 AUTHOR

Iain Murray

=head1 HISTORY

October 2002 - first version

=cut
# }}}

