Skip to content

Instantly share code, notes, and snippets.

@cfedde
Created September 9, 2013 19:21
Show Gist options
  • Save cfedde/6500228 to your computer and use it in GitHub Desktop.
Save cfedde/6500228 to your computer and use it in GitHub Desktop.
snowman
#!/usr/bin/perl
use Modern::Perl;
use Math::Complex;
my $ul = cplx(-2.1, 1.2);
my $lr = cplx( 0.6,-1.2);
my $sx = (Re($lr) - Re($ul))/79;
my $sy = (Im($lr) - Im($ul))/26;
sub mandlebrot {
my $c = shift;
my $z = 0;
for my $n (0..10) {
$z = $z * $z + $c;
return '.' if (abs($z) > 2);
}
return '*';
}
my $text = "";
for (my $y = Im($ul); $y >= Im($lr); $y += $sy) {
for (my $x = Re($ul); $x <= Re($lr); $x += $sx) {
my $c = cplx($x,$y);
print mandlebrot($c);
}
print "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment