>  기사  >  백엔드 개발  >  PHP에서 imageellipse() 함수를 사용하여 타원을 그리는 방법은 무엇입니까?

PHP에서 imageellipse() 함수를 사용하여 타원을 그리는 방법은 무엇입니까?

WBOY
WBOY앞으로
2023-09-09 14:29:01784검색

imageellipse()는 타원 그리기를 위해 PHP에 내장된 함수입니다. 성공하면 True를, 실패하면 False를 반환합니다.

Syntax

Bool imageellipse($image, $cx, $cy, $width, $height, $color)

Parameters

imageellipse()는 6개의 다른 매개변수를 사용합니다: $image, $ cx, $cy, $ 너비 , $ , $색상.

  • $image - 생성된 이미지의 크기입니다. imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에 의해 반환됩니다.

  • $cx - 중심의 X 좌표를 설정합니다.

  • $cy - 중심의 y 좌표를 설정합니다.

  • $width - 타원 너비를 설정합니다.

  • $height - 타원 높이를 설정합니다.

  • $Color - 타원의 색상을 설정합니다. imagecolorallocate() 함수에 의해 생성된 색상 식별자입니다.

반환 값

성공하면 True, 실패하면 False를 반환합니다.

예제 1

<?php
   // Create a blank image.
   $image = imagecreatetruecolor(700, 350);

   // Select the background color.
   $bg = imagecolorallocate($image, 0, 0, 0);

   // Fill the background with the color selected above.
   imagefill($image, 0, 0, $bg);

   // Choose a color for the ellipse.
   $col_ellipse = imagecolorallocate($image, 255, 255, 255);

   // Draw the ellipse.
   imageellipse($image, 325, 175, 500, 175, $col_ellipse);

   // Output the image.
   header("Content-type: image/png");
   imagepng($image);
?>

Output

PHP에서 imageellipse() 함수를 사용하여 타원을 그리는 방법은 무엇입니까?

예제 2

<?php
   //It creates the blank image or size of the image.
   $image = imagecreatetruecolor(700, 600);

   //Set the background color of the image.
   $bg = imagecolorallocate($image, 122, 122, 122);

   //Fill background with the above-selected color.
   imagefill($image, 0, 0, $bg);

   // set color of the ellipse.
   $col_ellipse = imagecolorallocate($image, 0, 255, 255);

   // Function to draw the ellipse.
   imageellipse($image, 250, 300, 300, 550, $col_ellipse);

   // Output of the image.
   header("Content-type: image/gif");
   imagepng($image);
?>

Output

PHP에서 imageellipse() 함수를 사용하여 타원을 그리는 방법은 무엇입니까?

위 내용은 PHP에서 imageellipse() 함수를 사용하여 타원을 그리는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제