use GD; if( scalar @ARGV == 0 ) { print STDERR "Usage: draw-field.pl || STDIN \n"; print STDERR " where t is time-step for which a graph is desired.\n"; exit; } $n = shift; $t0 = shift; $scale = shift; while( <> ) { chomp; unless( /^# data/ ) { next; } ( $t ) = /(\d+)/; if( $t == $t0 ) { last; } } ( $mn, $mx ) = ( 1e16, 0 ); while( <> ) { chomp; if( /^\s*$/ ) { last; } # blank line... ( $x, $y, $d ) = split; push @data, [ $x, $y, $d ]; $mn = ( $mn > $d ) ? $d : $mn; $mx = ( $mx < $d ) ? $d : $mx; print "$x $y $d\n"; } print "$mn $mx\n";exit; $n *= $scale; $img = new GD::Image( $n, $n, 1 ); $white = $img->colorResolve( 255, 255, 255 ); $black = $img->colorResolve( 0, 0, 0 ); $red = $img->colorResolve( 255, 0, 0 ); $img->filledRectangle( 0, 0, $n-1, $n-1, $white ); foreach $r ( @data ) { ( $x0, $y0 ) = ( $scale*$r->[0], $scale*$r->[1] ); ( $x1, $y1 ) = ( $x0 + $scale - 1, $y0 + $scale - 1 ); $img->filledRectangle( $x0, $y0, $x1, $y1, $red ); # $img->setPixel( $x0, $y0, $red ); } $img->string( gdMediumBoldFont, 2, 2, "t=$t", $black ); binmode STDOUT; print $img->png();