이미지 처리 및 GD imagearc
(PHP 4, PHP 5, PHP 7, PHP 8)
imagearc — Draws an arc
설명
imagearc( GdImage $image, int $center_x, int $center_y, int $width, int $height, int $start_angle, int $end_angle, int $color ): bool
imagearc()는 주어진 좌표를 중심으로 원호를 그립니다.
매개변수
image
- imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
center_x
- 중심의 x 좌표.
center_y
- 중심의 y 좌표.
width
- The arc width.
height
- The arc height.
start_angle
- 호 시작 각도(도).
end_angle
- 호 끝 각도(도). 0°는 3시 위치에 있으며 호는 시계 방향으로 그려집니다.
color
- imagecolorallocate()로 생성된 색상 식별자입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | image 는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
Examples
예제 #1 imagearc()로 원 그리기
<?php
// create a 200*200 image
$img = imagecreatetruecolor(200, 200);
// allocate some colors
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$blue = imagecolorallocate($img, 0, 0, 255);
// draw the head
imagearc($img, 100, 100, 200, 200, 0, 360, $white);
// mouth
imagearc($img, 100, 100, 150, 150, 25, 155, $red);
// left and then the right eye
imagearc($img, 60, 75, 50, 50, 0, 360, $green);
imagearc($img, 140, 75, 50, 50, 0, 360, $blue);
// output image in the browser
header("Content-type: image/png");
imagepng($img);
// free memory
imagedestroy($img);
?>
위의 예는 다음과 유사한 결과를 출력합니다.
기타
- imagefilledarc() - 부분 호를 그리고 채우기
- imageellipse() - 타원을 그립니다
- imagefilledellipse() - 채워진 타원 그리기