Skip to content

Commit

Permalink
Trigger Julia set creation on right click.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Dec 3, 2011
1 parent 1269323 commit 39ab24e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions bin/gtk-mandelbrot.pl
Expand Up @@ -267,7 +267,7 @@
my $counter = 0; my $counter = 0;
my ($x, $y); my ($x, $y);
loop ($y = 0; $y < $.height; $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++) { loop ($x = 0; $x < $.width; $x++) {
my $value = $.is-julia ?? julia($.c, $c) !! mandel($c); my $value = $.is-julia ?? julia($.c, $c) !! mandel($c);
$.stored-byte-array.Set($counter++, @red[$value]); $.stored-byte-array.Set($counter++, @red[$value]);
Expand Down Expand Up @@ -314,18 +314,26 @@
delta => ($lower-left.re - $upper-right.re) / $size, delta => ($lower-left.re - $upper-right.re) / $size,
width => $size, width => $size,
height => $size).BuildWindow; 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 Application.Run; # end of main program, it's all over when this returns


sub ButtonEvent($obj, $args) { #OK not used 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 { 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;
}
} }
} }


Expand Down

0 comments on commit 39ab24e

Please sign in to comment.