이미지 처리 및 GD imagerectangle

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

imagerectangle — 직사각형 그리기


설명

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

imagerectangle()은 지정된 좌표에서 시작하는 사각형을 만듭니다.


매개변수

image
imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
x1
왼쪽 상단 x 좌표.
y1
왼쪽 상단 y 좌표 0, 0은 이미지의 왼쪽 상단 모서리입니다..
x2
오른쪽 아래 x 좌표.
y2
오른쪽 하단 y 좌표.
color
imagecolorallocate()로 생성된 색상 식별자입니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


변경 로그

버전 설명
8.0.0 image는 이제 GdImage 인스턴스를 반환합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 Simple imagerectangle() 예제

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

// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 132, 135, 28);

// Draw three rectangles each with its own color
imagerectangle($canvas, 50, 50, 150, 150, $pink);
imagerectangle($canvas, 45, 60, 120, 100, $white);
imagerectangle($canvas, 100, 120, 75, 160, $green);

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

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

위의 예는 다음과 유사한 결과를 출력합니다.

function imagerectangle