이미지 처리 및 GD imagefilledpolygon

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

imagefilledpolygon — 채워진 다각형 그리기


설명

PHP 8.0.0의 서명(명명된 인수에서는 지원되지 않음)

imagefilledpolygon(GdImage $image, array $points, int $color): bool

대체 서명(PHP 8.1.0부터 더 이상 사용되지 않음)

imagefilledpolygon(
    GdImage $image,
    array $points,
    int $num_points,
    int $color
): bool
                

imagefilledpolygon()은 주어진 image에 채워진 폴리곤을 생성합니다.


매개변수

image
imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
points
다각형 꼭짓점의 x 및 y 좌표를 연속적으로 포함하는 배열입니다.
num_points
총 점(정점) 수(최소 3개 이상이어야 함).

두 번째 서명에 따라 이 매개변수가 생략되면 points에는 짝수의 요소가 있어야 하며 num_pointscount($points)/2로 가정됩니다.

color
imagecolorallocate()로 생성된 색상 식별자입니다.

반환 값

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


변경 로그

버전 설명
8.1.0 num_points 매개변수는 더 이상 사용되지 않습니다.
8.0.0 image는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 imagefilledpolygon() 예제

                  
<?php
// set up array of points for polygon
$values = array(
            40,  50,  // Point 1 (x, y)
            20,  240, // Point 2 (x, y)
            60,  60,  // Point 3 (x, y)
            240, 20,  // Point 4 (x, y)
            50,  40,  // Point 5 (x, y)
            10,  10   // Point 6 (x, y)
            );

// create image
$image = imagecreatetruecolor(250, 250);

// allocate colors
$bg   = imagecolorallocate($image, 0, 0, 0);
$blue = imagecolorallocate($image, 0, 0, 255);

// fill the background
imagefilledrectangle($image, 0, 0, 249, 249, $bg);

// draw a polygon
imagefilledpolygon($image, $values, 6, $blue);

// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
                  
                

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

function imagefilledpolygon


기타