PHP imagearc() function

In this chapter you will learn:

  1. What is PHP imagearc() function
  2. Syntax for PHP imagearc() function
  3. Parameter for PHP imagearc() function
  4. Return value for PHP imagearc() function
  5. Example - PHP imagearc() function

Description

imagearc() draws an arc of circle centered at the given coordinates.

Syntax

PHP imagearc() function has the following syntax.

bool imagearc(resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color )

Parameter

PHP imagearc() function has the following parameters.

  • image - An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
  • cx - x-coordinate of the center.
  • cy - y-coordinate of the center.
  • width - The arc width.
  • height - The arc height.
  • start - The arc start angle, in degrees.
  • end - The arc end angle, in degrees. 0? is located at the three-o'clock position, and the arc is drawn clockwise.
  • color - A color identifier created with imagecolorallocate().

Return

Returns TRUE on success or FALSE on failure.

Example

Drawing a circle with imagearc()

<?php//from  j  a  v  a 2 s  . c  om
$img = imagecreatetruecolor(200, 200);// create a 200*200 image
$blue  = imagecolorallocate($img,   0,   0, 255);// colors

// draw the head
imagearc($img, 140,  75,  50,  50,  0, 360, $blue);

// output image in the browser
header("Content-type: image/png");
imagepng($img);

imagedestroy($img);
?>

Next chapter...

What you will learn in the next chapter:

  1. What is PHP imagecreate() function
  2. Syntax for PHP imagecreate() function
  3. Parameter for PHP imagecreate() function
  4. Return value for PHP imagecreate() function
  5. Example - PHP imagecreate() function
  6. Example - PHP image script as img src
Home » PHP Tutorial » PHP Image Functions
PHP imagearc() function
PHP imagecreate() function
PHP imagecreatetruecolor () function
PHP imageellipse() function
PHP imagefilledarc() function
PHP imageline() function
PHP imagepolygon() function
PHP imagerectangle() function
PHP imagesetpixel() function
PHP imagettftext() function