Permalink
Browse files

Trigger Julia set creation on right click.

  • Loading branch information...
1 parent 1269323 commit 39ab24e9b27d16f32004d2821d544d34eeafce37 @colomon committed Dec 3, 2011
Showing with 16 additions and 8 deletions.
  1. +16 −8 bin/gtk-mandelbrot.pl
View
@@ -267,7 +267,7 @@
my $counter = 0;
my ($x, $y);
loop ($y = 0; $y < $.height; $y++) {
- my $c = $upper-right - $y * $.delta * i;
+ my $c = $.upper-right - $y * $.delta * i;
loop ($x = 0; $x < $.width; $x++) {
my $value = $.is-julia ?? julia($.c, $c) !! mandel($c);
$.stored-byte-array.Set($counter++, @red[$value]);
@@ -314,18 +314,26 @@
delta => ($lower-left.re - $upper-right.re) / $size,
width => $size,
height => $size).BuildWindow;
-FractalSet.new(is-julia => True,
- upper-right => $upper-right,
- delta => ($lower-left.re - $upper-right.re) / $size,
- width => $size,
- height => $size,
- c => 0 + 0i).BuildWindow;
Application.Run; # end of main program, it's all over when this returns
sub ButtonEvent($obj, $args) { #OK not used
+ my $index = $obj.GetData("Id").ToInt32();
+ my $set = @windows[$index];
+
+ say $args.Event.WHAT;
+ say $args.Event.X;
+ say $args.Event.Y;
given $args.Event.Button {
- when 3 { say "Create Julia now!"; }
+ when 3 {
+ my $c = $set.upper-right + $args.Event.X * $set.delta - $args.Event.Y * $set.delta * i;
+ FractalSet.new(is-julia => True,
+ upper-right => -5/4 + (5/4)i,
+ delta => (5 / 2) / $size,
+ width => $size,
+ height => $size,
+ :$c).BuildWindow;
+ }
}
}

0 comments on commit 39ab24e

Please sign in to comment.