Draws an ellipse centered at the specified coordinates.
PHP imageellipse() function has the following syntax.
bool imageellipse(resource $image , int $cx , int $cy , int $width , int $height , int $color )
PHP imageellipse() function has the following parameters.
Returns TRUE on success or FALSE on failure.
To draw circles and ellipses in PHP, use the imageellipse() function.
We provide the center point, and then specifying how high and how wide the ellipse should be.
imageellipse( $myImage, 90, 60, 160, 50, $myBlack );
This ellipse has its center on the pixel at (90,60). The width of the ellipse is 160 pixels and the height is 50 pixels.
To draw a circle, simply describe an ellipse that has the same width and height:
imageellipse( $myImage, 90, 60, 70, 70, $myBlack );
<?php// w w w . j a v a 2s . c o m
$image = imagecreatetruecolor(400, 300);
// Select the background color.
$bg = imagecolorallocate($image, 0, 0, 0);
// Fill the background with the color selected above.
imagefill($image, 0, 0, $bg);
// Choose a color for the ellipse.
$col_ellipse = imagecolorallocate($image, 255, 255, 255);
// Draw the ellipse.
imageellipse($image, 200, 150, 300, 200, $col_ellipse);
// Output the image.
header("Content-type: image/png");
imagepng($image);
?>