update : 2015.11.03
php.shukuma.com

검색:
 
 
Draw a rectangle

imagerectangle

(PHP 4, PHP 5, PHP 7)

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);
?>

위 예제의 출력 예시:

Output of example : Simple imagerectangle() example