
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Draw an Ellipse Using imageellipse Function in PHP
imageellipse() is an inbuilt function in PHP that is used to draw an ellipse. It returns True on success and False on failure.
Syntax
Bool imageellipse($image, $cx, $cy, $width, $height, $color)
Parameters
imageellipse() takes six different paramters: $image, $cx, $cy, $width, $height, $color.
$image − Creates the size of the image. It is returned by one of the image creation functions, such as imagecreatetruecolor().
$cx − Sets the x-coordinate of the center.
$cy − Sets the y-coordinate of the center.
$width − Sets the ellipse width.
$height − Sets the ellipse height.
$color − Sets the color of ellipse. A color identifier created by imagecolorallocate() function.
Return Values
It returns True on success and False on failure.
Example 1
<?php // Create a blank image. $image = imagecreatetruecolor(700, 350); // 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, 325, 175, 500, 175, $col_ellipse); // Output the image. header("Content-type: image/png"); imagepng($image); ?>
Output
Example 2
<?php //It creates the blank image or size of the image. $image = imagecreatetruecolor(700, 600); //Set the background color of the image. $bg = imagecolorallocate($image, 122, 122, 122); //Fill background with the above-selected color. imagefill($image, 0, 0, $bg); // set color of the ellipse. $col_ellipse = imagecolorallocate($image, 0, 255, 255); // Function to draw the ellipse. imageellipse($image, 250, 300, 300, 550, $col_ellipse); // Output of the image. header("Content-type: image/gif"); imagepng($image); ?>
Output
Advertisements