Well I played with your code, and what I think you need to do is reset the canvas size and scrollregion when you call the sub. The way your current code works, you make the fractal bigger, but never adjust the canvas size to accomodate it. This is as far as I got, before the cpu usage made me give it up. I added scrollregions, adjust $c_size with $scale, and set the $scale to 1.2 to troubleshoot easier. Anyways, click this a few times and watch what happens, compared to your original script.
#!/usr/bin/perl use warnings; use strict; use Tk; my $c_size = 100; my $scale = 1; my $mw = MainWindow -> new; my $canvas = $mw -> Scrolled('Canvas', -height=>$c_size, -width=>$c_size, -scrollregion => [0,0,$c_size,$c_size] )-> pack(-expand=>1 ,-fill=>'both'); $canvas -> Tk::bind('all', '<ButtonPress-1>' => \&MakeMan); &MakeMan(); MainLoop; sub MakeMan(){ my ($e, $canv_x, $canv_y)=(0,$c_size/2,$c_size/2); if($scale > 1){ $e = $canvas -> XEvent; $canv_x = $e->x; $canv_y = $e->y; } my $icount = 1; $c_size *= $scale; #problem here... my $i = -2/$scale + (($canv_y-($c_size/2)) / ($c_size/$scale));# + $ +lasti; my $rgb; while($icount <= $c_size){ #... and here... my $r = -2/$scale + (($canv_x-($c_size/2)) / ($c_size/$scale));# + + $lastr; my $rcount = 1; while($rcount <= $c_size){ my $tr = $r; my $ti = $i; $rgb = '#000000'; for my $n(1..15){ ($tr, $ti) = (($tr ** 2) - ($ti ** 2) + ($r), (2 * $tr * $ti) ++ ($i)); if((($tr * $tr) + ($ti * $ti)) > 4){ $rgb = '#ffffff'; last; } } $canvas -> createLine($rcount, $icount, $rcount+1, $icount, -fil +l => $rgb, -width => 1); $rcount ++; $r += (4/$scale)/$c_size; } $icount ++; $i += (4/$scale)/$c_size; } $scale = $scale * 1.2; $canvas->configure(-scrollregion=>[0,0,$c_size,$c_size]); $canvas->update; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re^3: Tk Zooming Fractal Problems by zentara
in thread Tk Zooming Fractal Problems by Melly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.