WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Prime Spiral is a image plotted with all the primes in a number spiral.
Categories : Algorithms, Graphics, GD image library, Math. Click here to Update Your Picture
Chao Xu
Date : May 15th 2007
Grade : 2 of 5 (graded 1 times)
Viewed : 2421
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Chao Xu
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
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.
Calculate the phase of the moon, and draw a png image of the moon
Categories : Algorithms, GD image library
Create a Thumbnail Using PHP, GD and Exif
Categories : PHP, Graphics, Exif, GD image library
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
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, 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
Reverse a given number
Categories : PHP, Beginner Guides, Algorithms, Math.
Get the root of a number with any precision
Categories : Algorithms, BC math, Math.
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
a simple pie-chart in php3 (with gd)
Categories : PHP, Graphics, GD image library, Charts and Graphs
Simple PHP Bar Graph using GD library
Categories : PHP, GD image library, Graphics, Arrays
Image Generation Class ( PNG Format )
Categories : PHP, GD image library, PHP Classes, Graphics
A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library
Simple histogram class with a constructor and printing methods (updated 1999/03/26)
Categories : Algorithms, Math.