GD 関数
PHP Manual

imagerectangle

(PHP 4, PHP 5)

imagerectangle矩形を描画する

説明

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

imagerectangle() は、指定した座標から始まる矩形を作成します。

パラメータ

image

imagecreatetruecolor() のような画像作成関数が返す画像リソース。

x1

左上の x 座標。

y1

左上の y 座標。 0, 0 が画像の左上隅を表します。

x2

右下の x 座標。

y2

右下の y 座標。

color

imagecolorallocate() で作成した色 ID。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 シンプルな imagerectangle() の例

<?php
// 200 x 200 の画像を作成します
$canvas imagecreatetruecolor(200200);

// 色を割り当てます
$pink imagecolorallocate($canvas255105180);
$white imagecolorallocate($canvas255255255);
$green imagecolorallocate($canvas13213528);

// 3 つの矩形をそれぞれの色で描画します
imagerectangle($canvas5050150150$pink);
imagerectangle($canvas4560120100$white);
imagerectangle($canvas10012075160$green);

// 出力してメモリから解放します
header('Content-Type: image/jpeg');

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

上の例の出力は、たとえば 以下のようになります。


GD 関数
PHP Manual
アダルトレンタルサーバー