Permalink
Browse files

Up max_iterations, simplify colors (dropping 144 lines of code in the…

… process), eliminate useless mandel sub.
  • Loading branch information...
1 parent 2d21a42 commit a458bb7c78569f00437396cf416873e7b884a08f @colomon committed Dec 4, 2011
Showing with 6 additions and 162 deletions.
  1. +6 −162 bin/gtk-mandelbrot.pl
View
@@ -4,7 +4,7 @@
my $size = @*ARGS[0] // 321;
$size = +$size;
-my $max_iterations = 50;
+my $max_iterations = 128;
my $upper-right = -2 + (5/4)i;
my $lower-left = 1/2 - (5/4)i;
@@ -83,150 +83,6 @@
"180 232 252",
"180 216 252",
"180 196 252",
- "0 0 112",
- "28 0 112",
- "56 0 112",
- "84 0 112",
- "112 0 112",
- "112 0 84",
- "112 0 56",
- "112 0 28",
- "112 0 0",
- "112 28 0",
- "112 56 0",
- "112 84 0",
- "112 112 0",
- "84 112 0",
- "56 112 0",
- "28 112 0",
- "0 112 0",
- "0 112 28",
- "0 112 56",
- "0 112 84",
- "0 112 112",
- "0 84 112",
- "0 56 112",
- "0 28 112",
- "56 56 112",
- "68 56 112",
- "84 56 112",
- "96 56 112",
- "112 56 112",
- "112 56 96",
- "112 56 84",
- "112 56 68",
- "112 56 56",
- "112 68 56",
- "112 84 56",
- "112 96 56",
- "112 112 56",
- "96 112 56",
- "84 112 56",
- "68 112 56",
- "56 112 56",
- "56 112 68",
- "56 112 84",
- "56 112 96",
- "56 112 112",
- "56 96 112",
- "56 84 112",
- "56 68 112",
- "80 80 112",
- "88 80 112",
- "96 80 112",
- "104 80 112",
- "112 80 112",
- "112 80 104",
- "112 80 96",
- "112 80 88",
- "112 80 80",
- "112 88 80",
- "112 96 80",
- "112 104 80",
- "112 112 80",
- "104 112 80",
- "96 112 80",
- "88 112 80",
- "80 112 80",
- "80 112 88",
- "80 112 96",
- "80 112 104",
- "80 112 112",
- "80 104 112",
- "80 96 112",
- "80 88 112",
- "0 0 64",
- "16 0 64",
- "32 0 64",
- "48 0 64",
- "64 0 64",
- "64 0 48",
- "64 0 32",
- "64 0 16",
- "64 0 0",
- "64 16 0",
- "64 32 0",
- "64 48 0",
- "64 64 0",
- "48 64 0",
- "32 64 0",
- "16 64 0",
- "0 64 0",
- "0 64 16",
- "0 64 32",
- "0 64 48",
- "0 64 64",
- "0 48 64",
- "0 32 64",
- "0 16 64",
- "32 32 64",
- "40 32 64",
- "48 32 64",
- "56 32 64",
- "64 32 64",
- "64 32 56",
- "64 32 48",
- "64 32 40",
- "64 32 32",
- "64 40 32",
- "64 48 32",
- "64 56 32",
- "64 64 32",
- "56 64 32",
- "48 64 32",
- "40 64 32",
- "32 64 32",
- "32 64 40",
- "32 64 48",
- "32 64 56",
- "32 64 64",
- "32 56 64",
- "32 48 64",
- "32 40 64",
- "44 44 64",
- "48 44 64",
- "52 44 64",
- "60 44 64",
- "64 44 64",
- "64 44 60",
- "64 44 52",
- "64 44 48",
- "64 44 44",
- "64 48 44",
- "64 52 44",
- "64 60 44",
- "64 64 44",
- "60 64 44",
- "52 64 44",
- "48 64 44",
- "44 64 44",
- "44 64 48",
- "44 64 52",
- "44 64 60",
- "44 64 64",
- "44 60 64",
- "44 52 64",
- "44 48 64",
);
constant $GTK = "gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f";
@@ -336,7 +192,7 @@
my $ur = $.upper-right;
my $width = $.width;
my $delta = $.delta;
-
+
my @rows = @.rows = ByteArray.new($width * 3) xx $.height;
my $y_;
@@ -350,10 +206,10 @@
my $c = $ur - $y * $delta * i;
while $counter < $counter_end {
- my $value = $is-julia ?? julia($julia-z0, $c) !! mandel($c);
- $row.Set($counter++, @red[$value]);
- $row.Set($counter++, @green[$value]);
- $row.Set($counter++, @blue[$value]);
+ my $value = $is-julia ?? julia($julia-z0, $c) !! julia($c, 0i);
+ $row.Set($counter++, @red[$value % 72]);
+ $row.Set($counter++, @green[$value % 72]);
+ $row.Set($counter++, @blue[$value % 72]);
$c += $delta;
}
}
@@ -504,18 +360,6 @@ ($obj, $args)
}
};
-sub mandel(Complex $c) {
- my $z = 0i;
- my $i;
- loop ($i = 0; $i < $max_iterations; $i++) {
- if $z.abs > 2 {
- return $i + 1;
- }
- $z = $z * $z + $c;
- }
- return 0;
-}
-
sub julia(Complex $c, Complex $z0) {
my $z = $z0;
my $i;

0 comments on commit a458bb7

Please sign in to comment.