PHP의 imagefilledellipse() 함수는 GD 라이브러리를 사용하여 이미지 위에 색이 채워진(fill) 타원을 그릴 때 사용하는 함수입니다. 도형의 외곽선만 그리는 imageellipse()와 달리, 이 함수는 내부까지 지정한 색상으로 완전히 채운 타원을 생성합니다.
문법(Syntax)
imagefilledellipse( $img, $cx, $cy, $width, $height, $color )
매개변수(Parameters)
img : 그림을 그릴 대상 이미지 리소스입니다. 일반적으로 imagecreatetruecolor() 함수로 생성한 빈 이미지를 사용합니다.
cx : 타원 중심점의 x좌표입니다.
cy : 타원 중심점의 y좌표입니다.
width : 타원의 너비(가로 길이)입니다.
height : 타원의 높이(세로 길이)입니다.
color : 타원을 채울 색상으로, imagecolorallocate() 함수로 생성한 색상 식별자를 전달합니다.
반환값(Return)
imagefilledellipse() 함수는 타원 그리기에 성공하면 TRUE를, 실패하면 FALSE를 반환합니다.
예제(Example)
다음은 imagefilledellipse() 함수를 활용해 배경 위에 채워진 타원을 그리는 예제 코드입니다.
<?php
$img = imagecreatetruecolor(450, 290);
$bgColor = imagecolorallocate($img, 140, 180, 140);
imagefill($img, 0, 0, $bgColor);
$ellipse = imagecolorallocate($img, 120, 50, 70);
imagefilledellipse($img, 225, 150, 400, 250, $ellipse);
header("Content-type: image/png");
imagepng($img);
?>
실행 결과(Output)
위 코드를 실행하면 연한 녹색 배경 위에 진한 붉은색으로 채워진 타원이 출력됩니다.
