use strict;
use warnings;
use GD;

my $image = new GD::Image(560,560);

# Polygon mit drei Punkten
my $polygon = new GD::Polygon;
$polygon->addPt(280,40);
$polygon->addPt(540,540);
$polygon->addPt(40,540);

# Farben allokieren
my $white = $image->colorAllocate(255, 255, 255);
my $black = $image->colorAllocate(0,0,0);

for my $i (0..30) 
  {
  my ($x1, $y1, $x2, $y2) = $polygon->bounds();
  $polygon->map($x1, $y1, $x2, $y2,
                $x1, $y1, $x2-$i, $y2-$i);
  $image->polygon($polygon, $black);
  }

open (IMG, ">", "dreieck.gif") || die "Oops: $!\n";
binmode(IMG);
print IMG $image->gif;
close (IMG);