PHP | imagefilledarc() Function (original) (raw)
Last Updated : 11 Jul, 2025
The imagefilledarc() function is an inbuilt function in PHP which is used to draws a partial arc centered at the specified coordinate in the given image. This function return True on success or False on failureSyntax:
bool imagefilledarc ( image,image, image,cx, cy,cy, cy,width, height,height, height,start, end,end, end,color, $style )
Parameters: This function accepts nine parameters as mentioned above and described below:
- $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image..
- $cx: This parameter is used to set the x-coordinate of the center.
- $cy: This parameter is used to set the y-coordinate of the center.
- $width: This parameter is used to set the arc width.
- $height: This parameter is used to set the arc height.
- $start: The arc start angle, in degrees.
- $end: The arc end angle, in degrees. 0° is located at the three-o'clock position, and the arc is drawn clockwise.
- $color: A color identifier created with imagecolorallocate().
- $style: Suggest how to fill the image and its values can be any one among the value listed below.
- IMG_ARC_PIE
- IMG_ARC_CHORD
- IMG_ARC_NOFILL
- IMG_ARC_EDGED
Return Values: This function returns True on success or False on failure. Below programs illustrate the imagefilledarc() function in PHP:Program 1:
php `
bg=bg = bg=white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); green=imagecolorallocate(green = imagecolorallocate(green=imagecolorallocate(img, 0, 255, 0); // make pie arc. $center_x = (int)WIDTH/2; $center_y = (int)HEIGHT/2; imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $green); imagefilledarc($img, centerx,center_x, centerx,center_y, WIDTH/2, HEIGHT/2, 0, 220, $green, IMG_ARC_PIE); // Flush image. header("Content-Type: image/png"); imagepng($img); ?>`
Output:
Program 2:
php `
red=imagecolorallocate(red = imagecolorallocate(red=imagecolorallocate(image, 0xFF, 0x00, 0x00); darkred=imagecolorallocate(darkred = imagecolorallocate(darkred=imagecolorallocate(image, 0x90, 0x00, 0x00); // Make the 3D effect for ($i = 60; i>50;i > 50; i>50;i--) { imagefilledarc($image, 50, i,100,50,75,360,i, 100, 50, 75, 360, i,100,50,75,360,darkred, IMG_ARC_PIE); } imagefilledarc($image, 50, 50, 100, 50, 75, 360, $red, IMG_ARC_PIE); // flush image header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?>`
Output:
Reference: https://www.php.net/manual/en/function.imagefilledarc.php