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 = imagecreate( 400, 100);
$basecolor = imagecolorallocate( $image, 255, 255, 255);
$blue = imagecolorallocate( $image, 0, 0, 255);
$green = imagecolorallocate( $image, 0, 255, 0);
$red = imagecolorallocate( $image, 255, 0, 0);
imagerectangle($image, 10, 10, 190, 90, $red);
imagefilledrectangle($image, 210, 10, 390, 90, $blue);
imagesetthickness($image, 5);
imagerectangle($image, 20, 20, 380, 80, $green);
imagegif($image);
imagedestroy($image);
?>
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
|
|
|