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:
- $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 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