imagefilledarc(): arc using PHP GD

Returns true or false based on success of failure.
$imageImage created using ImageCreate() or imagecreatetruecolor()
$center_xx coordinate of center ( X : Horizontal )
$center_yy coordinate of center ( Y : Vertical )
$widthWidth of the arc
$heightHeight of the arc
$start_angle Angle of the start in degree. 3 Oclock position is 0 degree.
$end_angle Angle of the end of the arc in degree.
$colorColor to fill the arc by using imagecolorallocate().

Drawing filled arc, circles & patterns using colours and angles by imagefilledarc() in PHP GD

filled are using imagefilledarc()
$filled_color = ImageColorAllocate ($im, 255, 0,0);

Creating full circle using imagefilledarc()

We need to maintain $width and $height equal , $start_angle should be 0 (degree ) and $end_angle should be 360 ( degree ). By using imagearc() we created one face, to this image now we will be adding eye balls by using imagefilledard().


Face with eye balls using imagefilledarac
header ("Content-type: image/jpeg");
$im = @ImageCreate ($width,$height) // added one pixel for border
or die ("Cannot Initialize new GD image stream");

$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 255, 0,0);
imagearc($im,150,150,290,290,0,360,$text_color); // outer face
imagearc($im,80,100,50,50,0,360,$text_color); // left eye 
imagearc($im,220,100,50,50,0,360,$text_color); // right eye
imagearc($im,150,150,150,150,45,135,$text_color); // mouth

$text_color = ImageColorAllocate ($im, 128, 128,0);
imagefilledarc($im,80,100,20,20,0,360,$text_color,IMG_ARC_PIE); // left eye ball 
imagefilledarc($im,220,100,20,20,0,360,$text_color,IMG_ARC_PIE); // right eye ball 

imagedestroy($im); //memory cleared. 
By changing the position of eye ball we can create different type of face ( emoji )
Face with eye balls in UP direction
Face with eye balls in LEFT direction
$move_left=0; // x position is not changed 
$move_top=15; // Y position is moved up 
imagefilledarc($im,80-$move_left,100-$move_top,20,20,0,360,$text_color,IMG_ARC_PIE); // left eye ball 
imagefilledarc($im,220-$move_left,100-$move_top,20,20,0,360,$text_color,IMG_ARC_PIE); // right eye ball 
Try to create different movement of eye balls and mouth arc representing different face expressions ( emoji )

Concentric circle using imagefilledarc()

Random numbers are gnerated between 1 and 255 for adding differnt colors. Common center for all the circles.
Filled concentric Circles using imagefilledarc
header ("Content-type: image/jpeg");
$im = @ImageCreate ($width,$height) // added one pixel for border
or die ("Cannot Initialize new GD image stream");
$gap=20; // change this value to increase the lines 
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 255, 0,0);
for($i=0;$i<=$width;$i +=$gap){
$r=rand(1,255); // random numbers 
$text_color = ImageColorAllocate ($im, $r, $g,$b);		

Imagejpeg ($im);
imagedestroy($im); //memory is removed. 
We can keep height and width of the arcs constant and change the starting and ending angles of the arcs. The $gap we will reduce here.
 Change in angles of Filled concentric Circles
GD functions GD imagearc() GD imagerectangle() imageellipse()
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    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-2022 All rights reserved worldwide Privacy Policy Disclaimer