function generate_mandelbrot($fname, $size, $min, $max, $iterations)
 {
     $img = ImageCreate($size[0], $size[1]);
     $colors = array();
     $colors['inside'] = imagecolorallocate($img, 0, 0, 0);
     Profiler::startTimer("palette");
     $palette = imagecreatefrompng("palette.png");
     for ($i = 0; $i < imagesx($palette); $i++) {
         $rgb = imagecolorat($palette, $i, 0);
         $colors[$i] = imagecolorallocate($img, $rgb >> 16 & 0xff, $rgb >> 8 & 0xff, $rgb & 0xff);
     }
     Profiler::stopTimer("palette");
     Profiler::startTimer("mainloop");
     for ($i = 0; $i < $size[0]; $i++) {
         for ($j = 0; $j < $size[1]; $j++) {
             Profiler::startTimer("math");
             $x = $min[0] + $i * (($max[0] - $min[0]) / ($size[0] - 1));
             $y = $min[1] + $j * (($max[1] - $min[1]) / ($size[1] - 1));
             $iteration = 0;
             $z0 = 0;
             $z1 = 0;
             $x2 = $y2 = 0;
             while ($iteration <= $iterations && $x2 + $y2 <= 4) {
                 $z1 = 2 * $z0 * $z1 + $y;
                 $z0 = $x2 - $y2 + $x;
                 $x2 = $z0 * $z0;
                 $y2 = $z1 * $z1;
                 $iteration++;
             }
             Profiler::stopTimer("math");
             Profiler::startTimer("setpixel");
             $color = $colors[$iteration == $iterations ? 'inside' : $iteration];
             ImageSetPixel($img, $i, $j, $color);
             Profiler::stopTimer("setpixel");
         }
     }
     Profiler::stopTimer("mainloop");
     Profiler::startTimer("saveimage");
     ImagePNG($img, $fname);
     Profiler::stopTimer("saveimage");
     //print Profiler::display();
 }
Beispiel #2
0
<?
include_once("profiler.inc.php");
$prof = new Profiler(true, true);

$prof->startTimer( "include" );
/* ========================= */
// Load pathvars etc.
/* ========================= */
require_once("vars.php");

require_once("XML/Serializer.php");
require_once("XML/Unserializer.php");

/* ========================= */
// Load basic functions
/* ========================= */
require_once("system/functions.php");
require_once("system/design.php");
require_once("system/system.php");
require_once("system/fetch.php");
require_once("system/paths.php");
require_once("system/filecache.php");
require_once("system/objectcache.php");
require_once("system/settings.php");
require_once("system/user.php");
require_once("system/class.php");
require_once("system/import.php");


/* ========================= */
// Se if we should run install