imagearc

Draws an arc

Description

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

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

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 Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Drawing a circle with imagearc

<?php

// create a 200*200 image
$img imagecreatetruecolor(200200);

// allocate some colors
$white imagecolorallocate($img255255255);
$red   imagecolorallocate($img255,   0,   0);
$green imagecolorallocate($img,   0255,   0);
$blue  imagecolorallocate($img,   0,   0255);

// draw the head
imagearc($img100100200200,  0360$white);
// mouth
imagearc($img10010015015025155$red);
// left and then the right eye
imagearc($img,  60,  75,  50,  50,  0360$green);
imagearc($img140,  75,  50,  50,  0360$blue);

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

// free memory
imagedestroy($img);

?>

The above example will output something similar to:

Output of example : Drawing a circle with imagearc()

See Also

  • imagefilledarc
  • imageellipse
  • imagefilledellipse