my $levels = 6;
my $side = 512;
my $height = get_height($side);
sub get_height { my($side) = @_; $side * sqrt(3) / 2 }
sub triangle {
my($x1, $y1, $x2, $y2, $x3, $y3, $fill, $animate) = @_;
my $svg;
$svg .= qq{\n \n\n}
: ' />';
return $svg;
}
sub fractal {
my( $x1, $y1, $x2, $y2, $x3, $y3, $r ) = @_;
my $svg;
$svg .= triangle( $x1, $y1, $x2, $y2, $x3, $y3 );
return $svg unless --$r;
my $side = abs($x3 - $x2) / 2;
my $height = get_height($side);
$svg .= fractal( $x1, $y1-$height*2, $x1-$side/2, $y1-3*$height, $x1+$side/2, $y1-3*$height, $r);
$svg .= fractal( $x2, $y1, $x2-$side/2, $y1-$height, $x2+$side/2, $y1-$height, $r);
$svg .= fractal( $x3, $y1, $x3-$side/2, $y1-$height, $x3+$side/2, $y1-$height, $r);
}
open my $fh, '>', 'run/sierpinski_triangle.svg';
print $fh <<'EOD',
';