이미지 처리 및 GD imageopenpolygon

(PHP 7 >= 7.2.0, PHP 8)

imageopenpolygon — 열린 다각형을 그립니다.


설명

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

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

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

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

imageopenpolygon()은 주어진 image에 열린 다각형을 그립니다. imagepolygon()과 달리 마지막 점과 첫 번째 점 사이에 선이 그려지지 않습니다.


매개변수

image
imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
points
폴리곤의 꼭짓점을 포함하는 배열, 예:
points[0] = x0
points[1] = y0
points[2] = x1
points[3] = y1
num_points
총 점(정점) 수(최소 3개 이상이어야 함).

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

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

반환 값

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


변경 로그

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

Examples

예제 #1 imageopenpolygon() 예제

                  
<?php
// Create a blank image
$image = imagecreatetruecolor(400, 300);

// Allocate a color for the polygon
$col_poly = imagecolorallocate($image, 255, 255, 255);

// Draw the polygon
imageopenpolygon($image, array(
        0,   0,
        100, 200,
        300, 200
    ),
    3,
    $col_poly);

// Output the picture to the browser
header('Content-type: image/png');

imagepng($image);
imagedestroy($image);
?>
                  
                

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

function imageopenpolygon


기타