#!perl

use Getopt::Std;

$opt_X = 79;
$opt_Y = 23; 
$opt_N = 100;
getopts('x:y:X:Y:N:') or die;

my $xsize = 4;
my $ysize = 4;

my $xc = 0;
my $yc = 0;

my ($xl, $xh, $yl, $yh) = (-$xsize/2, $xsize/2, -$ysize/2, $ysize/2);

my @result;

for my $xc (0 .. $opt_X-1) {
  print STDERR "$xc\n";
  for my $yc (0 .. $opt_Y-1) {
    my $n = $opt_N;
    my ($x, $y) = ($xl + $xc/$opt_X * $xsize,
                   $yl + $yc/$opt_Y * $ysize);
    my ($zx, $zy) = ($x, $y);
    while ($n-- && $zx * $zx + $zy * $zy < 4) {
      ($zx, $zy) = ($zx * $zx - $zy * $zy + $x,
                    2 * $zx * $zy + $y
                   );
    }
    my $r = $n <= 0 ? " " : "*";
    set(\@result, $xc, $yc, $r);
  }
}

print_result(\@result);

sub set {
  my ($c, $x, $y, $p) = @_;
  $c->[$y][$x] = $p;
}

sub print_result {
  my $c = shift;
  for (@$c) { 
    print join "", @$_;
    print "\n";
  }
}
