SDP2006
05-24-2004, 09:45 PM
So, for my summer bored day project (which will be about everyday), i decided to make a 'PHP City' with GD - lol.
Anyways, im having some trouble. I am trying to accomplish 'windows.' I have on my building one window, but it would be pointless to do 50 different functions over and over to make the 50 windows. I know there is, but I don't know how, to do it with a for(); loop. If someone could help, I would appreciate it!
Code - <?php
Header("Content-Type: image/png");
$image = array(1135, 688);
$img = ImageCreate($image[0], $image[1]) or die("Image WIDTHxHEIGHT could not be created.");
$colors = array( 'white' => imagecolorallocate($img, 255, 255, 255),
'black' => imagecolorallocate($img, 0, 0, 0),
'red' => imagecolorallocate($img, 255, 0, 0),
'yellow' => imagecolorallocate($img, 255, 255, 0),
'green' => imagecolorallocate($img, 0, 128, 0),
'blue' => imagecolorallocate($img, 0, 128, 255),
'purple' => imagecolorallocate($img, 128, 0, 128),
'skyblue' => imagecolorallocate($img, 128, 191, 255),
'brown' => imagecolorallocate($img, 98, 49, 49),
'grey' => imagecolorallocate($img, 128, 128, 128),
'lightgrey' => imagecolorallocate($img, 192, 192, 192),
'lightbrown' => imagecolorallocate($img, 128, 64, 0));
/////////////// SKY - BACKGROUND COLOR /////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFill($img, 0, 0, $colors['skyblue']);
/////////////// IMAGE BORDER ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageRectangle($img, 0, 0, 1134, 687, $colors['black']);
/////////////// SUN //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Imagefilledellipse($img, 80, 80, 150, 150, $colors['yellow']);
/////////////// GRASS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledEllipse($img, 500, 700, 1000, 100, $colors['green']);
/////////////// BAWLS BUILDING //////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledRectangle($img, 50, 175, 200, 686, $colors['lightgrey']);
ImageRectangle($img, 50, 175, 200, 688, $colors['black']);
ImageFilledRectangle($img, 60, 225, 85, 250, $colors['blue']); /* WINDOW */
ImageRectangle($img, 60, 225, 85, 250, $colors['black']);
ImageString($img, 5, 75, 180, " B A W L S ", $colors['brown']);
ImageString($img, 5, 76, 181, " B A W L S ", $colors['brown']);
ImageString($img, 5, 58, 195, " A M E R I C A ", $colors['brown']);
ImageString($img, 5, 59, 196, " A M E R I C A ", $colors['brown']);
ImageFilledRectangle($img, 400, 175, 100, 100, $colors['yellow']);
/////////////// RASMUS HOUSE //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledRectangle($img, 408, 550, 620, 650, $colors['lightbrown']);
ImageRectangle($img, 408, 550, 620, 650, $colors['brown']);
ImageString($img, 5, 445, 550, "THE RASMUS HOUSE", $colors['white']);
ImageString($img, 2, 480, 561, "Fine Dining", $colors['white']);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImagePNG($img);
Imagedestroy($img);
?>
On web http://stevie.f2o.org/city.php
Thanks to all
:D
Anyways, im having some trouble. I am trying to accomplish 'windows.' I have on my building one window, but it would be pointless to do 50 different functions over and over to make the 50 windows. I know there is, but I don't know how, to do it with a for(); loop. If someone could help, I would appreciate it!
Code - <?php
Header("Content-Type: image/png");
$image = array(1135, 688);
$img = ImageCreate($image[0], $image[1]) or die("Image WIDTHxHEIGHT could not be created.");
$colors = array( 'white' => imagecolorallocate($img, 255, 255, 255),
'black' => imagecolorallocate($img, 0, 0, 0),
'red' => imagecolorallocate($img, 255, 0, 0),
'yellow' => imagecolorallocate($img, 255, 255, 0),
'green' => imagecolorallocate($img, 0, 128, 0),
'blue' => imagecolorallocate($img, 0, 128, 255),
'purple' => imagecolorallocate($img, 128, 0, 128),
'skyblue' => imagecolorallocate($img, 128, 191, 255),
'brown' => imagecolorallocate($img, 98, 49, 49),
'grey' => imagecolorallocate($img, 128, 128, 128),
'lightgrey' => imagecolorallocate($img, 192, 192, 192),
'lightbrown' => imagecolorallocate($img, 128, 64, 0));
/////////////// SKY - BACKGROUND COLOR /////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFill($img, 0, 0, $colors['skyblue']);
/////////////// IMAGE BORDER ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageRectangle($img, 0, 0, 1134, 687, $colors['black']);
/////////////// SUN //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Imagefilledellipse($img, 80, 80, 150, 150, $colors['yellow']);
/////////////// GRASS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledEllipse($img, 500, 700, 1000, 100, $colors['green']);
/////////////// BAWLS BUILDING //////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledRectangle($img, 50, 175, 200, 686, $colors['lightgrey']);
ImageRectangle($img, 50, 175, 200, 688, $colors['black']);
ImageFilledRectangle($img, 60, 225, 85, 250, $colors['blue']); /* WINDOW */
ImageRectangle($img, 60, 225, 85, 250, $colors['black']);
ImageString($img, 5, 75, 180, " B A W L S ", $colors['brown']);
ImageString($img, 5, 76, 181, " B A W L S ", $colors['brown']);
ImageString($img, 5, 58, 195, " A M E R I C A ", $colors['brown']);
ImageString($img, 5, 59, 196, " A M E R I C A ", $colors['brown']);
ImageFilledRectangle($img, 400, 175, 100, 100, $colors['yellow']);
/////////////// RASMUS HOUSE //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImageFilledRectangle($img, 408, 550, 620, 650, $colors['lightbrown']);
ImageRectangle($img, 408, 550, 620, 650, $colors['brown']);
ImageString($img, 5, 445, 550, "THE RASMUS HOUSE", $colors['white']);
ImageString($img, 2, 480, 561, "Fine Dining", $colors['white']);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ImagePNG($img);
Imagedestroy($img);
?>
On web http://stevie.f2o.org/city.php
Thanks to all
:D