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

$p=imagecreate(200,200);
$b=imagecolorallocate($p,0,0,0);
$o=rand(0,32757)/32767*6.28;
$og=rand(0,32757)/32767*6.28;
$ob=rand(0,32757)/32767*6.28;
for (
$x=0$x<252$x++) {
    if (
$_REQUEST['c']==1) {
    
$d=($x/254)*6.28+$o;
    
imagecolorallocate($p,(sin($d)+1)*127,(sin($d+$og)+1)*127,(sin($d+$ob)+1)*127);
    } else {
    
imagecolorallocate($p,255,255,255);
    }
}
$s=30;
$x=100;
$y=100;
$d=3.1415*(5/4);
$sd=0;
$no=rand(100,300);
for (
$t=0$t<$no$t++){
    
$err=1;
//    echo $t.'<br>';
//    flush();
    
while($err==1) {
    
$err=0;
    
$a[$t]['x']=$x;
    
$a[$t]['y']=$y;
    
$a[$t]['d']=$d;
    
$a[$t]['s']=$s;

    
$sd+=((rand(0,32767)/16384)-1)*.1;
    for (
$i=0$i<($t-2) && $err==0$i++) {
        if (
sqrt(pow($x-$a[$i]['x'],2)+pow($y-$a[$i]['y'],2))<($a[$i]['s']+$s)/6) {
        
$s=$s-1;
//        echo "s=$s<br>";
//        flush();
        
$err=1;
        }

    }
    if (
$s<5) {
        
$l=$l+1;
        if (
$l==1000) exit(0);
        
$f=rand(0,$t);
//        echo "To $f<br>";
//        flush();
        
$d=$a[$f]['d']+(((rand(0,32767)/16384)-1)*3.1415);
        
$s=$a[$f]['s'];
        
$x=$a[$f]['x']+sin($d)*$s/4;
        
$y=$a[$f]['y']+cos($d)*$s/4;
        
$sd=0;
    }
    }
    
$c=($s/30)*253;
    
imagefilledellipse($p,200-$a[$t]['x'],$a[$t]['y'],$a[$t]['s']/2,$a[$t]['s']/2,$c);
    
imagefilledellipse($p,$a[$t]['x'],$a[$t]['y'],$a[$t]['s']/2,$a[$t]['s']/2,$c);
    
imagefilledellipse($p,200-$a[$t]['x'],200-$a[$t]['y'],$a[$t]['s']/2,$a[$t]['s']/2,$c);
    
imagefilledellipse($p,$a[$t]['x'],200-$a[$t]['y'],$a[$t]['s']/2,$a[$t]['s']/2,$c);

    
$x=$x+sin($d)*$s/4;
    
$y=$y+cos($d)*$s/4;
    
$d=$d+$sd;
    
$s=$s*.95;

}
imagepng($p);
?>