Andrew's code for Drawing Complex Functions

Complex Graph1 Complex Graph2

FIRST WORKER CODE FOLLOWS

<?php    // PHP worker script drawing complex functions

// create a blank image that is 200 pixels wide and 200 pixels tall             
$image imagecreate(200200);

// create a color and fill (paint) the work area  
// set the color RGB (255, 255, 255), which is WHITE  
$white imagecolorallocate($image255255255);

//  fill the entire image    
imagefilledrectangle($image00200200$white);

// === first function

// create another color    
$blue imagecolorallocate($image00255);

// init vars              
$center 100;
$PI pi();
$a 1;
$b 1;
$m 12;
$n1 5;
$n2 6;
$n3 48;

// create the graphic     
for($f 0$f <= $PI$f += 0.0001)
{
    
$rpow((pow(abs(cos($m*$f/4)/$a),$n2) + pow(abs(sin($m*$f/4)/$b), $n3)), -(1/$n1));
    
$x $center $r cos ($f) * 35;
    
$y $center $r sin ($f) * 35;
    
imagesetpixel($image$x$y$blue);
}

// create yet another color        
$red imagecolorallocate($image25500);

// === second function

// change vars           
$a 1;
$b 1;
$m 8;
$n1 5;
$n2 6;
$n3 24;

// create another graphic and place it over the original graphic
for($f 0$f <= $PI$f += 0.0001)
{
    
$rpow((pow(abs(cos($m*$f/4)/$a),$n2) + pow(abs(sin($m*$f/4)/$b), $n3)), -(1/$n1));
    
$x $center $r cos ($f) * 35;
    
$y $center $r sin ($f) * 35;
    
imagesetpixel($image$x$y$red);
}

// tell the server    what's coming, deliver it, and destroy it     
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);


SECOND WORKER CODE FOLLOWS

<?php    // PHP worker script drawing a fractal


// create a blank image that is 200 pixels wide and 200 pixels tall             
$image imagecreate(200200);

// create a color and fill (paint) the work area
// set the color RGB (255, 255, 255), which is WHITE      
$white imagecolorallocate($image255255255);
imagefilledrectangle($image00200200$white);

// create another color        
$red imagecolorallocate($image25500);

// init vars                
$x 200;
$y 200;
$corners[0] = array('x' => 100'y' =>  10);
$corners[1] = array('x' =>   0'y' => 190);
$corners[2] = array('x' => 200'y' => 190);

// create the graphic        
for ($i 0$i 100000$i++)
{
    
imagesetpixel($imageround($x), round($y), $red);
    
$a rand(02);
    
$x = ($x $corners[$a]['x']) / 2;
    
$y = ($y $corners[$a]['y']) / 2;
}

// tell the server    what's coming, deliver it, and destroy it     
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);