#!/usr/bin/perl

use GD;

$img = new GD::Image(300,300,1);
$img->fill(10,10,color(255,255,255));

for($x=0;$x<120;$x++) {
    for($y=0;$y<120;$y++) {
	if(int(rand(2) + 1) > 1) {
	    $img->setPixel($x,$y,color(0,0,0));
	}
    }
}

print "Content-Type: image/png\n\n";
binmode STDOUT;
print $img->png;

sub color {
    my($r,$g,$b) = @_;
    if(!defined($pal{"$r\_$g\_$b"})) {
        $pal{"$r\_$g\_$b"} = $img->colorAllocate($r,$g,$b);
    }
    return $pal{"$r\_$g\_$b"};
}
