PHP | imagefilledellipse() Function
The imagefilledellipse() function is an inbuilt function in PHP which is used to draw the filled ellipse. It draws the ellipse with specified center coordinate.
Syntax:
bool imagefilledellipse( $image, $cx, $cy, $width, $height, $color )
Parameters: This function accepts six parameters as mentioned above and described below:
- $image: The imagecreatetruecolor() function is used to create a blank image in a given size.
- $cx: x-coordinate of the center.
- $cy: y-coordinate of the center.
- $width: The ellipse width.
- $height: The ellipse height.
- $color: The fill color. A color identifier created with imagecolorallocate().
Return Value: This function returns TRUE on success or FALSE on failure.
Below programs illustrate the imagefilledellipse() function in PHP.
Program 1:
<?php
$image = imagecreatetruecolor(500, 300);
$bg = imagecolorallocate( $image , 205, 220, 200);
imagefill( $image , 0, 0, $bg );
$col_ellipse = imagecolorallocate( $image , 0, 102, 0);
imagefilledellipse( $image , 250, 150, 400, 250, $col_ellipse );
header( "Content-type: image/png" );
imagepng( $image );
?>
|
Output:
Program 2:
<?php
$image = imagecreatetruecolor(300, 500);
$bg = imagecolorallocate( $image , 205, 220, 200);
imagefill( $image , 0, 0, $bg );
$col_ellipse = imagecolorallocate( $image , 0, 102, 0);
imagefilledellipse( $image , 150, 250, 250, 400, $col_ellipse );
header( "Content-type: image/png" );
imagepng( $image );
?>
|
Output:
You can try making a circle too using the same function.
Related Article: PHP | imageellipse() Function
Reference: http://php.net/manual/en/function.imagefilledellipse.php
Last Updated :
23 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...