Welcome to Gaia! ::

My Design :: Web and Graphic Design [HTML CSS PHP]

Back to Guilds

XHTML, CSS, jQuery, Javascript, PHP, mySQL, MORE! 

Tags: design, graphics, html, jquery, javascript 

Reply Server Side Programming
Bah session or somthing >_< (PHP)

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

Uru Wolf

PostPosted: Mon Dec 10, 2007 1:29 pm


I have got a script that create a psudo-binary pattern for a site bg. The problem I have is this:

User Image - Blocked by "Display Image" Settings. Click to show. | User Image - Blocked by "Display Image" Settings. Click to show.

See? They come out the same. Here is the script as it stands:


/**
* @author Steven West @ Ewolf UK.com
* @contact info[at]ewolfuk[dot]com
* @copyright 2007
* @created 28:11:2007 15:47
*/

header("Content-type: image/png")
header('Cache-Control: no-cache, must-revalidate')
header('Pragma: no-cache')

$im = imagecreate(20,94)
imagecolorallocate($im,0x00,0x00,0x00)

$textcolor = imagecolorallocate($im,0x00,0xFF,0x00)

$count=0;
$y = 1;
while ( $count <= 5 )
{
$first = rand(0,10000000)
$txt = ($first == 10000000)?'2':rand(0,1)
imagestring($im,4,6,$y,$txt,$textcolor)
$count++;
$y = $count * 15;
}
$y=null;
imagepng($im)
imagedestroy($im)
?>


the random one-in-ten million:

$first = rand(0,10000000)
$txt = ($first == 10000000)?'2':rand(0,1)

Randomly enters a 2 into the binary, with a chance of 1/10,000,000 as a joke.
As you can see the problem is that all the images are the same for the page >_< How can this be fixed?
PostPosted: Sun Dec 23, 2007 2:31 pm


You're calling the back.php code only once in the css file, so the background is only generated once, and then repeated.

Have you thought of making it multiple columns so that it 'seems' more random,

Page
Image

/**
* @author Steven West @ Ewolf UK.com
* @contact info[at]ewolfuk[dot]com
* @copyright 2007
* @created 28:11:2007 15:47
*/

##change number of columns quickly and easily##
$noColumns=10;

header("Content-type: image/png")
header('Cache-Control: no-cache, must-revalidate')
header('Pragma: no-cache')

$w=$noColumns*20; //No columns times column width
$im = imagecreate($w,94)
imagecolorallocate($im,0x00,0x00,0x00)

$textcolor = imagecolorallocate($im,0x00,0xFF,0x00)
for($i=0;$i<$noColumns;$i++){
$count=0;
$y = 1;
while ( $count <= 5 )
{
$x=((20*$i)+6) // offset of 20 for each column plus 6 to center
$first = rand(0,10000000)
$txt = ($first == 10000000)?'2':rand(0,1)
imagestring($im,4,$x,$y,$txt,$textcolor)
$count++;
$y = $count * 15;
}
$y=null;
}
imagepng($im)
imagedestroy($im)
?>

Zionna


Uru Wolf

PostPosted: Mon Dec 24, 2007 2:33 am


Ah yes, I had forgotten the image was only called once >_< Thanks for your help.
Reply
Server Side Programming

 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum