PHP | imageellipse() Function
Last Updated :
25 Jul, 2018
The imageellipse() function is an inbuilt function in PHP which is used to draw an ellipse. This function returns TRUE on success or FALSE on failure.
Syntax:
bool imageellipse( $image, $cx, $cy, $width, $height, $color )
Parameters: This function accepts six 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: x-coordinate of the center.
- $cy: y-coordinate of the center.
- $width: The ellipse width.
- $height: The ellipse height.
- $color: It sets the color of ellipse. A color identifier created by imagecolorallocate() function.
Return Value: It returns TRUE on success or FALSE on failure.
Below programs illustrate the imageellipse() function in PHP:
Program 1:
<?php
$image_size = imagecreatetruecolor(500, 300);
$background_color = imagecolorallocate( $image_size , 255, 255, 255);
imagefill( $image_size , 0, 0, $background_color );
$ellipse_color = imagecolorallocate( $image_size , 0, 0, 0);
imageellipse( $image_size , 250, 150, 400, 250, $ellipse_color );
header( "Content-type: image/png" );
imagepng( $image_size );
?>
|
Output:
Program 2:
<?php
$image = imagecreatetruecolor(300, 500);
$bg = imagecolorallocate( $image , 0, 102, 0);
imagefill( $image , 0, 0, $bg );
$col_ellipse = imagecolorallocate( $image , 255, 255, 255);
imageellipse( $image , 150, 250, 250, 400, $col_ellipse );
header( "Content-type: image/png" );
imagepng( $image );
?>
|
Output:
Reference: http://php.net/manual/en/function.imageellipse.php
Share your thoughts in the comments
Please Login to comment...