<?
##
## ePerl Demo: on-the-fly GIF image showing the Web216 color palette
## Copyright (c) 1996,1997 Ralf S. Engelschall, All Rights Reserved.
##
## This ePerl source file entirely consists of one single
## ePerl block which generates a complete GIF image plus
## the corresponding HTTP headers to introduce it as such.
##
use GD;
my $im = new GD::Image(190,130);
$im->interlaced('true');
for (my $b = 0; $b <= 255; $b += 51) {
for (my $r = 0; $r <= 255; $r += 51) {
for (my $g = 0; $g <= 255; $g += 51) {
my $x = (($b / 51) % 3)*60 + (60-($r / 51) * 10);
my $y = (($b / 51) < 3 ? 0 : 1)*60 + (60-($g / 51) * 10);
my $col = $im->colorAllocate($r,$g,$b);
$im->rectangle($x, $y, $x+9, $y+9, $col);
$im->fill($x+2, $y+2, $col);
}
}
}
my $C = $im->gif;
print "Content-type: image/gif\n";
print "Content-length: " . length($C) . "\n"; # strips the newline above
print "\n";
print $C;
!>