이미지openpolygon() 주어진 이미지에 열린 다각형을 그리는 데 사용되는 PHP의 내장 함수입니다.
구문
bool imageopenpolygon(resource $image,array $points,int $num_points,int $color)
매개변수
이미지openpolygon() $image, $points, $num_points 및 $color의 네 가지 매개변수를 사용합니다.
-
$이미지 − 작업할 이미지 리소스를 지정합니다.
-
$이미지 − 작업할 이미지 리소스를 지정합니다.
-
$포인트 − 폴리곤의 포인트를 지정합니다.
-
$num_points - 포인트 수를 지정합니다. (정점) 포인트의 총 수는 3개 이상이어야 합니다.
-
$color − 이 매개변수는 다각형의 색상을 지정합니다.
반환 값
이미지openpolygon() 성공하면 True, 실패하면 False를 반환합니다.
예시 1
<?php
// Create a blank image using imagecreatetruecolor() function.
$img = imagecreatetruecolor(700, 300);
// Allocate a color for the polygon
$col_poly = imagecolorallocate($img, 0, 255, 0);
// Draw the polygon
imageopenpolygon($img, array(
0, 0,
100, 200,
400, 200
),
3,
$col_poly);
// Output the picture to the browser
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?> 출력

예시 2
<?php
// Create a blank image using imagecreatetruecolor() function.
$image = imagecreatetruecolor(700, 300);
// allocate the colors
$blue = imagecolorallocate($image, 0, 255, 255);
// Six points of the array
$points = array(
60, 130,
130, 230,
280, 230,
350, 130,
210, 30,
60, 130
);
// Create a polygon
imageopenpolygon($image, $points, 6, $blue);
// Output to the browser
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?> 출력
