<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Mandelbrot in PHP</title>
	<atom:link href="http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/</link>
	<description>The blog for absolutely nothing!</description>
	<lastBuildDate>Fri, 25 Jun 2010 07:02:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Cipher</title>
		<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/comment-page-1/#comment-663</link>
		<dc:creator>Cipher</dc:creator>
		<pubDate>Thu, 28 Jan 2010 20:05:59 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=12#comment-663</guid>
		<description>Terribly sorry about this. Here is the code. provide ?w=500&amp;h=500 for width and height, there are no default values.
&lt;code&gt;
&lt;?php
/* Timing */
set_time_limit(0);
function microtime_float() {
    list($usec, $sec) = explode(&#039; &#039;, microtime());
    return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
/* Lil Mandlebrot Set Fractal Generator */
define (&#039;IMAGE_WIDTH&#039;, intval($_GET[&#039;w&#039;]));
define (&#039;IMAGE_HEIGHT&#039;, intval($_GET[&#039;h&#039;]));
define (&#039;X_MIN&#039;, -1.8);
define (&#039;X_MAX&#039;, 0.5);
define (&#039;Y_MIN&#039;, -1);
define (&#039;Y_MAX&#039;, 1);
define (&#039;MAX_ITERATIONS&#039;, 100); // if you change this to a number bigger than 200, make sure you create a new palette.png
$image = imagecreate(IMAGE_WIDTH, IMAGE_HEIGHT);
// Load the palette to find colours
$colours = array();
$palette = imagecreatefrompng(&#039;palette.png&#039;);
$i_width = imagesx($palette);
for ($i=0; $i&lt;$i_width; ++$i) {
    $rgb = imagecolorat($palette, $i, 0);
    $colours[$i] = imagecolorallocate($image, ($rgb &gt;&gt; 16) &amp; 0xFF, ($rgb &gt;&gt; 8) &amp; 0xFF, $rgb &amp; 0xFF);
}
$colours[MAX_ITERATIONS+1] = imagecolorallocate($image, 0, 0, 0);
$value_Y = (Y_MAX - Y_MIN) / (IMAGE_HEIGHT-1);
$value_X = (X_MAX - X_MIN) / (IMAGE_WIDTH-1);
for ($i=0; $i&lt;IMAGE_WIDTH; ++$i) {
    for ($j=0; $j&lt;IMAGE_HEIGHT; ++$j) {
        // What values of x and y does this pixel represent?
        $x = X_MIN+$i*$value_X;
        $y = Y_MIN+$j*$value_Y;
        // C=x+yi
        $iteration = 0;
        $z0 = 0; // The initial value of z is 0+0i
        $z1 = 0; // The initial value of z is 0+0i
        //$magnitude = 0;
        // Optimization: Store x^2 and y^2 so we don&#039;t have to keep calculating it
        $x2 = 0;
        $y2 = 0;
        // If the &#124;z&#124; &gt; 2 ever, then the sequence will tend to infinity so we can exit the loop
        while ($iteration &lt;= MAX_ITERATIONS &amp;&amp; $x2+$y2 &lt;= 4) {
            // In order to get the next term in the sequence
            // we need to square the previous number and then add
            // the original complex number
            $k0 = $z0;
            $k1 = $z1;
            // z is a complex number. When we square a complex number in the form x+yi:
            // New real component: x^2-y^2
            // New imaginary component: 2*real*imaginary
            $z0 = $x2 - $y2+ $x;
            $z1 = 2 * $k0 * $k1 + $y;
            $x2 = $z0 * $z0;
            $y2 = $z1 * $z1;
            ++$iteration;
        }
		imagesetpixel($image, $i, $j, $colours[$iteration]);
    }
}
$time_end = microtime_float();
$black = imagecolorallocate($image, 255, 255, 255);
$font = &#039;E:\Documents\Websites\arial.ttf&#039;;
imagettftext($image, 12, 0, 12, 12, $black, $font, ($time_end - $time_start));
header(&#039;Content-type: image/png&#039;);
imagepng($image);
?&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Terribly sorry about this. Here is the code. provide ?w=500&#038;h=500 for width and height, there are no default values.<br />
<code><br />
< ?php<br />
/* Timing */<br />
set_time_limit(0);<br />
function microtime_float() {<br />
    list($usec, $sec) = explode(' ', microtime());<br />
    return ((float)$usec + (float)$sec);<br />
}<br />
$time_start = microtime_float();<br />
/* Lil Mandlebrot Set Fractal Generator */<br />
define ('IMAGE_WIDTH', intval($_GET['w']));<br />
define ('IMAGE_HEIGHT', intval($_GET['h']));<br />
define ('X_MIN', -1.8);<br />
define ('X_MAX', 0.5);<br />
define ('Y_MIN', -1);<br />
define ('Y_MAX', 1);<br />
define ('MAX_ITERATIONS', 100); // if you change this to a number bigger than 200, make sure you create a new palette.png<br />
$image = imagecreate(IMAGE_WIDTH, IMAGE_HEIGHT);<br />
// Load the palette to find colours<br />
$colours = array();<br />
$palette = imagecreatefrompng('palette.png');<br />
$i_width = imagesx($palette);<br />
for ($i=0; $i<$i_width; ++$i) {<br />
    $rgb = imagecolorat($palette, $i, 0);<br />
    $colours[$i] = imagecolorallocate($image, ($rgb >> 16) &#038; 0xFF, ($rgb >> <img src='http://skypher.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &#038; 0xFF, $rgb &#038; 0xFF);<br />
}<br />
$colours[MAX_ITERATIONS+1] = imagecolorallocate($image, 0, 0, 0);<br />
$value_Y = (Y_MAX - Y_MIN) / (IMAGE_HEIGHT-1);<br />
$value_X = (X_MAX - X_MIN) / (IMAGE_WIDTH-1);<br />
for ($i=0; $i<image_width ; ++$i) {<br />
    for ($j=0; $j<IMAGE_HEIGHT; ++$j) {<br />
        // What values of x and y does this pixel represent?<br />
        $x = X_MIN+$i*$value_X;<br />
        $y = Y_MIN+$j*$value_Y;<br />
        // C=x+yi<br />
        $iteration = 0;<br />
        $z0 = 0; // The initial value of z is 0+0i<br />
        $z1 = 0; // The initial value of z is 0+0i<br />
        //$magnitude = 0;<br />
        // Optimization: Store x^2 and y^2 so we don't have to keep calculating it<br />
        $x2 = 0;<br />
        $y2 = 0;<br />
        // If the |z| > 2 ever, then the sequence will tend to infinity so we can exit the loop<br />
        while ($iteration < = MAX_ITERATIONS &#038;&#038; $x2+$y2 <= 4) {<br />
            // In order to get the next term in the sequence<br />
            // we need to square the previous number and then add<br />
            // the original complex number<br />
            $k0 = $z0;<br />
            $k1 = $z1;<br />
            // z is a complex number. When we square a complex number in the form x+yi:<br />
            // New real component: x^2-y^2<br />
            // New imaginary component: 2*real*imaginary<br />
            $z0 = $x2 - $y2+ $x;<br />
            $z1 = 2 * $k0 * $k1 + $y;<br />
            $x2 = $z0 * $z0;<br />
            $y2 = $z1 * $z1;<br />
            ++$iteration;<br />
        }<br />
		imagesetpixel($image, $i, $j, $colours[$iteration]);<br />
    }<br />
}<br />
$time_end = microtime_float();<br />
$black = imagecolorallocate($image, 255, 255, 255);<br />
$font = 'E:\Documents\Websites\arial.ttf';<br />
imagettftext($image, 12, 0, 12, 12, $black, $font, ($time_end - $time_start));<br />
header('Content-type: image/png');<br />
imagepng($image);<br />
?><br />
</image_width></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/comment-page-1/#comment-662</link>
		<dc:creator>George</dc:creator>
		<pubDate>Thu, 28 Jan 2010 00:54:38 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=12#comment-662</guid>
		<description>are you going to post the code anytime soon?</description>
		<content:encoded><![CDATA[<p>are you going to post the code anytime soon?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zylox</title>
		<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/comment-page-1/#comment-14</link>
		<dc:creator>zylox</dc:creator>
		<pubDate>Fri, 27 Jun 2008 14:22:33 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=12#comment-14</guid>
		<description>hi! have you got any news on this? i would be interested, also in the sourcecode!</description>
		<content:encoded><![CDATA[<p>hi! have you got any news on this? i would be interested, also in the sourcecode!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/comment-page-1/#comment-3</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Tue, 27 May 2008 10:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=12#comment-3</guid>
		<description>Nice example, curious for the results.
Lets use the DH server for real-time fractal rendering ;)</description>
		<content:encoded><![CDATA[<p>Nice example, curious for the results.<br />
Lets use the DH server for real-time fractal rendering <img src='http://skypher.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
