search for in the  
<imagepstextimagerotate>
Last updated: Thu, 19 May 2005

imagerectangle

(PHP 3, PHP 4, PHP 5)

imagerectangle -- Draw a rectangle

Description

int imagerectangle ( resource image, int x1, int y1, int x2, int y2, int col )

imagerectangle() creates a rectangle of color col in image image starting at upper left coordinate x1, y1 and ending at bottom right coordinate x2, y2. 0, 0 is the top left corner of the image.



User Contributed Notes
imagerectangle
j dot gizmo at aon dot at
01-Oct-2004 11:33
this function essentially only draws four lines.
usually this is not a problem, but if you are using a color with an alpha value (with transparency), the four corner pixels will be darker than the connection lines. this is due to the fact, that the lines all start on the corner pixel, thus always two lines are on top of each other at the corner.

<?php
$col
= imagecolorcreatealpha($img, $r, $g, $b, $transparency)

//doesn't work, corners too dark
imagerectangle($img, $x1, $y1, $x2, $y2, $col );

//proper drawing
$col = imagecolorcreatealpha($img, $r, $g, $b, $transparency)
imageline($img, $x1, $y1, $x2, $y1, $col ); //top
imageline($img, $x1, $y2, $x2, $y2, $col ); //bottom
imageline($img, $x1, $y1+1, $x1, $y2-1, $col ); //left
imageline($img, $x2, $y1+1, $x2, $y2-1, $col ); //right
?>
eustaquiorangel at yahoo dot com
17-Dec-2002 11:21
If you want an empty rectangle, I mean, just the borders, fill it first with the ImageFilledRectangle function with the background color and then draw it with this function.
jbenson at technologist dot com
28-Nov-2000 12:41
For those wanting a function to draw a grid I've created one.  I hope this is the right place to post it.

function ImageGrid(&$im,$startx,$starty,$width,$height,$xcols,$yrows,&$color) {

for ( $x=0; $x < $xcols; $x++ ) {
   for ( $y=0; $y < $yrows; $y++ ) {
     $x1 = $startx + ($width * $x);
     $x2 = $startx + ($width * ($x+1));
     $y1 = $starty + ($height * $y);
     $y2 = $starty + ($height * ($y+1));
     ImageRectangle($im, $x1, $y1, $x2, $y2, $color);
   }
}

} // end function ImageGrid

<imagepstextimagerotate>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT