# append to the other part of the script use Imager; # Generate sensible filename for image. my $filename = sprintf('Koch-Depth%02i.png', $depth); # Image dimensions my $max_x = 1000; my $max_y = 400; my $img = Imager->new(xsize => $max_x, ysize => $max_y); my $color = Imager::Color->new( 0, 0, 255 ); # blue # Scale dimensions by 200. @$_ = map $_*200, @$_ foreach @$edges; foreach (@$edges) { $img->line( color => $color, x1 => $max_x / 2 + $_->[0], # start y1 => $max_y - 50 - $_->[1], x2 => $max_x / 2 + $_->[2], # end y2 => $max_y - 50 - $_->[3], ); } $img->write(file=>$filename) or die $img->errstr;