Skip to content
Browse files

Add write-file method.

  • Loading branch information...
1 parent a6d92f7 commit e2113d1d760f3b76c60f7bddcab66579569cfc45 @colomon committed Dec 4, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 bin/gtk-mandelbrot.pl
View
24 bin/gtk-mandelbrot.pl
@@ -293,6 +293,27 @@
}
return 0;
}
+
+ my $file-count = 0;
+
+ method write-file() {
+ my $filename = $.is-julia ?? "julia-{ $file-count++ }.ppm" !! "mandelbrot-{ $file-count++ }.ppm";
+ say "Starting to write $filename";
+
+ my $file = open $filename, :w;
+ $file.say: "P3";
+ $file.say: "$.width $.height";
+ $file.say: "255";
+ for @.rows -> $row {
+ for ^$row.Length -> $i {
+ $file.print: $row.GetValue($i).ToString ~ " ";
+ $file.say: "" if $i % 4 == 3;
+ }
+ $file.say: "";
+ }
+ $file.close;
+ say "$filename written";
+ }
}
Application.Init;
@@ -362,6 +383,9 @@ ($obj, $args)
when 'm' | 'M' {
$set.increase-max-iterations;
}
+ when 's' | 'S' {
+ $set.write-file;
+ }
}
}

0 comments on commit e2113d1

Please sign in to comment.
Something went wrong with that request. Please try again.