Open In App

PHP | imagefilledarc() Function

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 failure

Syntax:



bool imagefilledarc ( $image, $cx, $cy, $width, $height, $start, 
$end, $color, $style )

Parameters: This function accepts nine parameters as mentioned above and described below:

Return Values: This function returns True on success or False on failure.



Below programs illustrate the imagefilledarc() function in PHP:

Program 1:




<?php
  
define("WIDTH", 300);
define("HEIGHT", 300);
       
// Create image.
$img = imagecreate(WIDTH, HEIGHT);
   
// Allocate colors.
$bg = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
$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, $center_x, $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
  
// Create image
$image = imagecreatetruecolor(100, 100);
  
// Allocate some colors
$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);
  
// Make the 3D effect
for ($i = 60; $i > 50; $i--) {
   imagefilledarc($image, 50, $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: http://php.net/manual/en/function.imagefilledarc.php


Article Tags :