in reply to ulam's spiral too slow

As to drawing dot-by-dot in Tk, you might want to look at Dr. Mu's response to my first posting, which was a question about how to manipulate individual pixels in Tk.

HTH.

Replies are listed 'Best First'.
Re^2: ulam's spiral too slow
by atcroft (Abbot) on Apr 20, 2007 at 06:47 UTC

    Does the following code help any?

    With it, I was able to generate (on an Athlon XP 2900+) 348_100 points (590**2 points) in 83 wallclock seconds, 220_900 (470**2) in 47 wallclock seconds, and 10_000 (100**2) in 2 wallclock seconds.

    (As an aside, it would probably be much quicker if there were a formula for determining the position based on the value, but I couldn't wrap my mind around one that would work. Anyone?)

    HTH.

      thanks very much atcroft , many ideas in your program, which will help. while searching in http://groups.google.com/group/comp.lang.perl.tk
      i have found that we can draw the screen gradually, ie dot by dot with animation by inserting the line
      $mw->update;
      after
      ${$img}->put( q{BLUE}, -to => ( $image_w_2 + $p{x}, $image_h_2 + $p{y} ) ) if ( $numbers$i );
      so we can enjoy watching the process of drawing.