Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
i edited BronzeWing's code and made it faster so it still has a cool update effect(as long as line 72 is not commeted). it's faster than Aristotle's code when line 72 is commeted out and almost as fast when its not commeted out
#!/usr/bin/perl -w use strict; use Tk; ############ # Settings # ############ my $Epsilon = 8; my @Lines = ([200, 300, 600, 300]); my @Points = map $_/90, ( #my design best with 90 for @Points (-20,20), (20,10), (90,-10), (120,20), #original design best with 96 for @Points #( 0, 0), #( 10, 20), #( 90, -20), #(100, 0), ); #you can put your own colors here sub randomc { my $i = rand(2); if ($i>=0 && $i<1) {return '#b10000';} if ($i>=1 && $i<2) {return '#b15128';} } ########### # Widgets # ########### my $Main = new Tk::MainWindow; $Main->Label('-textvariable'=>\(my $Status="Initializing..."))->pack; my $Canvas = $Main->Canvas( '-width'=>900, '-height'=>700, '-background'=>'#000000' )->pack; my @LineItems = @Lines; ############# # Main Loop # ############# $Main->update; while (++our $i<10) { # change 10 if u need more $Status = "Iteration $i..."; for (my $Line=0;$Line<=@Lines-1;$Line++) { my @Line = @{$Lines[$Line]}; if (abs($Line[2]-$Line[0])>$Epsilon or abs($Line[3]-$Line[1])> +$Epsilon) { my @NewLines; my @NewItems; for (my $Point=0;$Point<$#Points-1;$Point+=2) { my ($X1, $Y1, $X2, $Y2) = @Line; push @NewLines, my $NewLine = [ $Line[0]+($Line[2]-$Line[0])*$Points[$Point+0] + ($Line[3]-$Line[1])*$Points[$Point+1], $Line[1]+($Line[3]-$Line[1])*$Points[$Point+0] - ($Line[2]-$Line[0])*$Points[$Point+1], $Line[0]+($Line[2]-$Line[0])*$Points[$Point+2] + ($Line[3]-$Line[1])*$Points[$Point+3], $Line[1]+($Line[3]-$Line[1])*$Points[$Point+2] - ($Line[2]-$Line[0])*$Points[$Point+3] ]; push @NewItems, $Canvas->createLine(@$NewLine, '-fill' + => randomc()); } splice(@Lines,$Line,1,@NewLines); #$Line += $#NewLines;#good for some fractals not for others wi +thout commet you need more iterations and update effect isnt as good } $Main->Exists ? $Main->update : exit; #with this line commeted + out its like Aristotle's Code } $Main->Exists ? $Main->update : exit; last unless 2; } $Status = "Done."; MainLoop;

In reply to Re: Re: Linear Fractal Generator by Monkey_Sc
in thread Linear Fractal Generator by BronzeWing

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2022-10-03 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (14 votes). Check out past polls.

    Notices?