imageellipse(): ellipse using PHP GD

imageellipse($image,$center_x,$center_y,$width,$height,$color)
$imageImage created using ImageCreate() or imagecreatetruecolor()
$center_xx coordinate of center ( X : Horizontal )
$center_yy coordinate of center ( Y : Vertical )
$widthWidth of the ellipse
$heightHeight of the ellipse
$colorColor of the border by using imagecolorallocate().
imageellipse

Creating full circle using imageellipse()

We need to maintain $width and $height equal to create a circle.

Example

Circles using imageellipse
<?Php
header ("Content-type: image/jpeg");
$width=301;$height=301;
$im = @ImageCreate ($width, $height) 
 or die ("Cannot Initialize new GD image stream");
ImageColorAllocate($im,255,255,255);
$text_color=ImageColorAllocate($im,255,0,0);   
imageellipse($im,150,150,290,290,$text_color); // outer face
imageellipse($im,80,100,50,50,$text_color); // left eye 
imageellipse($im,220,100,50,50,$text_color); // right eye
imageellipse($im,150,200,70,10,$text_color); // mouth
Imagejpeg ($im);
imagedestroy($im); //memory is cleared.
?>

Concentric circle using imageellipse()

Common center for all the circles.
Circles using imageellipse
<?Php
header ("Content-type: image/jpeg");
$width=601;$height=601;$gap=20;
$im = @ImageCreate ($width, $height) 
 or die ("Cannot Initialize new GD image stream");
ImageColorAllocate($im,255,255,255);
$text_color=ImageColorAllocate($im,0,255,255);   
for($i=0;$i<=$width;$i +=$gap){
imageellipse($im,$width/2,$height/2,$width-$i,$height-$i,$text_color);
}
Imagejpeg ($im);
 imagedestroy($im); //memory is cleared.
?>
Change the colours of the circle by using random numbers between 1 and 255 ( R G B )
Color Circles using imageellipse
<?Php
header ("Content-type: image/jpeg");
$width=601;$height=601;$gap=20;
$im = @ImageCreate ($width, $height) 
 or die ("Cannot Initialize new GD image stream");
ImageColorAllocate($im,255,255,255);
$text_color=ImageColorAllocate($im,0,255,255);   
for($i=0;$i<=$width;$i +=$gap){
    $r=rand(1,255);
    $g=rand(1,255);
    $b=rand(1,255);	
    $text_color = ImageColorAllocate ($im, $r, $g,$b);    
imageellipse($im,$width/2,$height/2,$width-$i,$height-$i,$text_color);
}
Imagejpeg ($im);
imagedestroy($im); //memory is cleared.
?>
GD functions imagefilledellipse() imagefilledarc() imagearc() imagerectangle()

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    GD functions in PHP for handling images & graphics

    How to check GD support in PHP
    Header for an image in browser
    Drawing of graphic lines using GD
    Plotting line graph by drawing data from table
    Adding vertical grid to line graph
    Adding rectangles using imagerectangle()
    Imagearc drawing arc and circle
    Imagefilledarc drawing filled arc and circle
    Resizing and adding border to Images
    Script for Watermarking image on the fly using PHP GD
    Generate image by using user input form data

    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer