DJ Mike's Tutorials: PHP

< ^ >


Rectangles

You can make hollow rectangles with imagerectangle() or filled rectangles with imagefilledrectangle(). Both require six arguments: an image resource, the coordinates for the top-left corner, the coordinates for the bottom-right corner and a color resource. The following code was used to draw the red rectangle in the image above:

imagerectangle($image, 10, 10, 190, 90, $red);

and the next block of code drew the blue rectangle

imagefilledrectangle($image, 210, 10, 390, 90, $blue);


You can use imagesetthickness() to make the lines thicker as I did with the green rectangle:

imagesetthickness($image, 5);
imagerectangle($image, 20, 20, 380, 80, $green);



<?
header
("Content-type: image/gif");
$image imagecreate400100);
$basecolor imagecolorallocate$image255255255);

$blue imagecolorallocate$image00255);
$green imagecolorallocate$image02550);
$red imagecolorallocate$image25500);

imagerectangle($image101019090$red);
imagefilledrectangle($image2101039090$blue);

imagesetthickness($image5);
imagerectangle($image202038080$green);

imagegif($image);
imagedestroy($image);
?>


Blank Banner



The image above shows how you can use concentric rectangles of different shades to make a simple banner.



<?
header
("Content-type:image/gif");
$image=imagecreate(400,100);

# define colors
$basecolor=imagecolorallocate($image,100,100,175);
$dark=imagecolorallocate($image,0,0,135);
$blue=imagecolorallocate($image,60,60,255);

#makerectangles
imagefilledrectangle($image,5,5,395,95,$dark);
imagefilledrectangle($image,10,10,390,90,$blue);

imagegif($image);
imagedestroy($image);
?>


You can add offset different colored text strings on top of each other to make 3D text



< ^ >


Created by DJ Mike from Santa Barbara

DJ Mike


Dance Away Santa Barbara's Home Page
<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>