imagefilledrectangle

(PHP 4, PHP 5, PHP 7, PHP 8)

imagefilledrectangleDraw a filled rectangle

Опис

imagefilledrectangle(
    GdImage $image,
    int $x1,
    int $y1,
    int $x2,
    int $y2,
    int $color
): bool

Creates a rectangle filled with color in the given image starting at point 1 and ending at point 2. 0, 0 is the top left corner of the image.

Параметри

image

Об'єкт GdImage, що повертається однією з функцій створення зображення, такою як imagecreatetruecolor().

x1

x-coordinate for point 1.

y1

y-coordinate for point 1.

x2

x-coordinate for point 2.

y2

y-coordinate for point 2.

color

The fill color. Ідентифікатор кольору, створений за допомогою imagecolorallocate().

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Журнал змін

Версія Опис
8.0.0 Тепер image має бути примірником GdImage. Раніше очікувався gd-resource.

Приклади

Приклад #1 imagefilledrectangle() usage

<?php
// Create a 55x30 image
$im = imagecreatetruecolor(55, 30);
$white = imagecolorallocate($im, 255, 255, 255);

// Draw a white rectangle
imagefilledrectangle($im, 4, 4, 50, 25, $white);

// Save the image
imagepng($im, './imagefilledrectangle.png');
?>

Поданий вище приклад виведе щось схоже на:

Output of example : imagefilledrectangle()