<?php
header
("Content-type: image/png");

error_reporting(E_ALL);
ini_set ("display_errors",false);
ini_set ("log_errors",true);

if (isset(
$_GET['xsize']))
    
$xsize=$_GET['xsize'];
else
    
$xsize=256;

if (isset(
$_GET['ysize']))
    
$ysize=$_GET['ysize'];
else
    
$ysize=256;

$im=imagecreate($xsize,$ysize
    or die (
"cannot initialize new gd image stream");
    
for (
$i=0;$i<255;$i++)
    if (isset(
$_GET['bg_mode'])) {
        if (
$_GET['bg_mode']==-1)
            
$colors[]=imagecolorallocate($im,30,0,100);
        elseif (
$_GET['bg_mode']==1)
            
$colors[]=imagecolorallocate($im,rand(0,$i 188),rand(0,$i %120),rand(0,$i));
        elseif (
$_GET['bg_mode']==2)
            
$colors[]=imagecolorallocate($im,rand(0,120),rand(0,100),rand(0,255));
        elseif (
$_GET['bg_mode']==3)
            
$colors[]=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
        elseif (
$_GET['bg_mode']==4)
            
$colors[]=imagecolorallocate($im,rand(0,$i),rand(0,$i),rand(0,$i));
        elseif (
$_GET['bg_mode']==5)
            
$colors[]=imagecolorallocate($im,$i/1.4,$i/2,$i);
        else 
            
/* this makes a purplish background with random streaks */
            
$colors[]=imagecolorallocate($im,$i/rand(1,4),$i/rand(1,20),$i);
    }
    else 
        
/* this makes a purplish background with random streaks */
        
$colors[]=imagecolorallocate($im,$i/rand(1,4),$i/rand(1,20),$i);
for (
$x=0;$x<$xsize;$x++) 
    for (
$y=0;$y<$ysize;$y++)
        if (isset(
$_GET['op'])) {
            
/* this makes a pretty cool shaped pattern */
            
if ($_GET['op']==1)
                
imagesetpixel($im,$x,$y,$colors[($x $y) % 256]);
            elseif (
$_GET['op']==2)
                
imagesetpixel($im,$x,$y,$colors[($x $y) % 256]);
            elseif (
$_GET['op']==3)
        
/* lines starting with an @ are ones that I have found to
        produce errors, which are suppressed by the @ */
                
@imagesetpixel($im,$x,$y,$colors[($x $y) % 256]);
            else
                @
imagesetpixel($im,$x,$y,$colors[($x $y) % 256]);
        }
        elseif (
$_GET['bg_mode']==-1)
            
imagesetpixel($im,$x,$y,$colors[0]);
    else    
            @
imagesetpixel($im,$x,$y,$colors[($x $y) % 256]);
imagepng($im);
imagedestroy($im);
?>