www.hanno-rein.de | Bilder | Pi
Pi
So sehen die ersten 10000 Ziffern von Pi aus
Quelltext:
<?
$im = imagecreate(400,400);
$col =array();
for($i=0;$i<10;$i++){
$f = (int)($i*255/10);
$col[$i] = ImageColorAllocate ($im,$f,$f,$f);
}
$col[0] = ImageColorAllocate ($im,255,0,0);
$col[1] = ImageColorAllocate ($im,0,255,0);
$col[2] = ImageColorAllocate ($im,0,0,255);
$col[3] = ImageColorAllocate ($im,0,255,255);
$col[4] = ImageColorAllocate ($im,255,0,255);
$col[5] = ImageColorAllocate ($im,255,255,0);
$col[6] = ImageColorAllocate ($im,255,255,255);
$col[7] = ImageColorAllocate ($im,0,0,0);
$col[8] = ImageColorAllocate ($im,128,128,128);
$col[9] = ImageColorAllocate ($im,200,128,0);
$handle = fopen("pi.txt","r");
for($i=0;$i<400;$i++){
for($j=0;$j<400;$j++){
if (($j-200)*($j-200)+($i-200)*($i-200)<178*178){
$wert=(int)(fread($handle,1));
imagesetpixel ($im,$i,$j,$col[$wert]);
}
}
}
fclose($handle);
header ("Content-type: image/png");
imagepng($im);
?>
http://www.hanno-rein.de/bilder/27/?printable=true
(c) Hanno Rein 2020