docs
[mirrors/Programs.git] / perl / mandelbrot.pl
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 my @chars=split(//, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890');
6 #print $chars[2];
7
8 for(my $i=1000;$i<1060;$i++) { for(my $j=0;$j<10170;$j++) {
9 my $x0 = $i;
10 my $y0 = $j;
11
12 my $x = 0;
13 my $y = 0;
14
15 my $iteration = 0;
16 my $max_iteration = 1000;
17
18 while ( $x*$x + $y*$y <= (2*2) && $iteration < $max_iteration ) {
19 my $xtemp = $x*$x - $y*$y + $x0;
20 $y = 2*$x*$y + $y0;
21 $x = $xtemp;
22 $iteration++;
23 }
24
25 my $color;
26 if ( $iteration == $max_iteration ) {
27 $color = 0;
28 } else {
29 $color = int($iteration/100);
30 }
31 #print $chars[$color];
32
33 if ( $iteration < $max_iteration/100 ) {
34 $color = 0;
35 } else {
36 $color = 1;
37 }
38 print $color;
39
40 } print "\n"; }
This page took 0.295828 seconds and 4 git commands to generate.