Computer >> 컴퓨터 >  >> 프로그램 작성 >> PHP

PHP의 imagepolygon() 함수

<시간/>

imagepolygon() 함수는 다각형을 그리는 데 사용됩니다.

구문

bool imagepolygon( $img, $points, $num_points, $color)

매개변수

  • $img :imagecreatetruecolor() 함수로 빈 이미지를 만듭니다.
  • $포인트 :다각형 정점이 있는 배열입니다.
  • $num_points :다각형의 총 정점 수입니다.
  • $color :imagecolorallocate() 함수로 생성된 색상 식별자입니다.

돌아가기

imagepolygon() 함수는 성공하면 TRUE를, 실패하면 FALSE를 반환합니다.

예시

다음은 예입니다.

<?php
   $img = imagecreatetruecolor(400, 300);
   $color = imagecolorallocate($img, 120, 160, 190);
   $bgcolor = imagecolorallocate($img, 10, 100, 50);  
   imagefill($img, 0, 0, $bgcolor);
   imagepolygon($img, array(
      50, 50,
      150, 200,
      340, 200
   ),
   3,
   $color);
   header('Content-type: image/png');
   imagepng($img);
   imagedestroy($img);
?>

출력

다음은 출력입니다.

PHP의 imagepolygon() 함수