GD and Image 함수 목록
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

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를 반환합니다.

예제

Example #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 and Image 함수 목록
PHP Manual