-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathmandelbrot.php
More file actions
executable file
·60 lines (56 loc) · 1.27 KB
/
mandelbrot.php
File metadata and controls
executable file
·60 lines (56 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
/**
* This file is part of PHP-Compiler, a PHP CFG Compiler for PHP code
*
* @copyright 2015 Anthony Ferrara. All rights reserved
* @license MIT See LICENSE at the root of the project for more info
*/
function mandel(): void
{
$w1 = 50;
$h1 = 150;
$recen = -.45;
$imcen = 0.0;
$r = 0.7;
$s = 0;
$rec = 0;
$imc = 0;
$re = 0;
$im = 0;
$re2 = 0;
$im2 = 0;
$x = 0;
$y = 0;
$w2 = 0;
$h2 = 0;
$color = 0;
$s = 2 * $r / $w1;
$w2 = 40;
$h2 = 12;
for ($y = 0; $y <= $w1; $y = $y + 1) {
$imc = $s * ($y - $h2) + $imcen;
for ($x = 0; $x <= $h1; $x = $x + 1) {
$rec = $s * ($x - $w2) + $recen;
$re = $rec;
$im = $imc;
$color = 1000;
$re2 = $re * $re;
$im2 = $im * $im;
while (((($re2 + $im2) < 1000000) && $color > 0)) {
$im = $re * $im * 2 + $imc;
$re = $re2 - $im2 + $rec;
$re2 = $re * $re;
$im2 = $im * $im;
$color = $color - 1;
}
if ($color == 0) {
echo '_';
} else {
echo '#';
}
}
echo "\n";
}
}
mandel();