GD Функции
PHP Manual

imagerectangle

(PHP 4, PHP 5)

imagerectangleDraw a rectangle

Описание

bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )

imagerectangle() creates a rectangle starting at the specified coordinates.

Список параметров

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x1

Upper left x coordinate.

y1

Upper left y coordinate 0, 0 is the top left corner of the image.

x2

Bottom right x coordinate.

y2

Bottom right y coordinate.

color

A color identifier created with imagecolorallocate().

Возвращаемые значения

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

Примеры

Пример #1 Simple imagerectangle() example

<?php
// Create a 200 x 200 image
$canvas imagecreatetruecolor(200200);

// Allocate colors
$pink imagecolorallocate($canvas255105180);
$white imagecolorallocate($canvas255255255);
$green imagecolorallocate($canvas13213528);

// Draw three rectangles each with its own color
imagerectangle($canvas5050150150$pink);
imagerectangle($canvas4560120100$white);
imagerectangle($canvas10012075160$green);

// Output and free from memory
header('Content-Type: image/jpeg');

imagejpeg($canvas);
imagedestroy($canvas);
?>

Результатом выполнения данного примера будет что-то подобное:


GD Функции
PHP Manual