|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
Made by Chao Xu (WebDevLogs.com)
You need a prime counting function, it can be finded here :
http://www.weberdev.com/get_example-4635.html
| <?php
$size = 500;
$prime = esprime($size*$size);
$image = imagecreate($size,$size);
imagecolorallocate($image,255,255,255);
$color = imagecolorallocate($image,0,0,0);
$size2=$size/2;
$n = 2;$t = true;$sn=4;
$midu=2;$midl=4;$midd=6;$midr=8;
$i = 0;
while($n<$size){
if($prime[$i]<=$sn){
$p = $prime[$i++];
if($t){//even
if($p <= $sn-$n){
$x = $n/2;
$y = $midu - $p;
}else{
$x = $midl -$p;
$y = -$n/2;
}
}else{//odd
if($p <= $sn-$n){
$x = (-$n/2)+0.5;
$y = $p - $midd;
}else{
$x = $p - $midr;
$y = ($n/2)-0.5;
}
}
imagesetpixel($image,$x+$size2,$y+$size2,$color);
}else{
++$n;
$sn = $n * $n;
$t = !$t;
if($t){
$midu = $sn-$n*1.5+1;
$midl = $sn-$n*0.5+1;
}else{
$midd = $sn-$n*1.5+1.5;
$midr = $sn-$n*0.5+0.5;
}
}
}
header("Content-type: image/png");
imagepng($image);
?> | | |
|
| Diffusion-Limited Aggregation visualization Categories : PHP, Graphics, Algorithms, Math. | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | PHP Image Compression using GD library Categories : PHP, Compression, GD image library, Graphics | | | Line graphics generation library written in PHP + GD library (spanish comments) Categories : PHP, Graphics, GD image library | | | imageMarker v 3.00 with new advanced features Categories : PHP, PHP Classes, Graphics, GD image library | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Library of math functions to expand the functionality of PHP3. Version 1.2.1 fixes a major problem with the gcd function.
Categories : Algorithms, PHP, Math. | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | | | Simple histogram class with a constructor and printing
methods (updated 1999/03/26) Categories : Algorithms, Math. | | | Show the steps for converting a number from a given base to base 10. Shows the steps involved in converting a number from a given base to base 10. Categories : PHP, Math., Algorithms | | | Prime number finder (Sieve of Erastothenes) Categories : PHP, Algorithms, Math. | | | Image Generation Class ( PNG Format ) Categories : PHP, GD image library, PHP Classes, Graphics | | | Generate image with random number (CAPTCHA) Categories : PHP, GD image library, Graphics, Security | | | a simple pie-chart in php3 (with gd) Categories : PHP, Graphics, GD image library, Charts and Graphs | | | Display a bar chart based on random values. Categories : Graphics, PHP, GD image library, Charts and Graphs | |
|
|
|