Drawing On Our Image: Rectangles - Page 6
December 15, 2000
If you've picked up on any of the trends in this chapter, you'll
have guessed by now that the function to create a rectangle in
PHP is ImageRectangle():
ImageRectangle(image_id, x1, y1, x2, y2, color_id);
| The arguments correspond to the image identifier, the x
and y coordinates of the top left-hand corner of the rectangle,
the x and y coordinates of the bottom right-hand corner of the
rectangle, and the identifier for the color we want it drawn
in. |
|
Pretty straightforward, right? Here's the code, which now adds a
box whose top right-hand corner is at x = 150, y = 65, the same
as the center of the circle.
<?php
//draw3.php
Header("Content-type: image/jpeg");
$image = ImageCreate(200,150);
$gray = ImageColorAllocate($image,204,204,204);
$blue = ImageColorAllocate($image,0,0,255);
ImageLine($image,10,10,150,30,$blue);
ImageArc($image,150,65,70,70,0,360,$blue);
ImageRectangle($image,10,65,150,140,$blue);
ImageJPEG($image);
ImageDestroy($image);
?>
| This now returns the following image: |
|
Drawing On Our Image: Circles - Page 5
Beginning PHP4
Putting It All Together - Page 7
|