imagefilledarc

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagefilledarcDraw a partial arc and fill it

Description

imagefilledarc(
    GdImage $image,
    int $center_x,
    int $center_y,
    int $width,
    int $height,
    int $start_angle,
    int $end_angle,
    int $color,
    int $style
): bool

Draws a partial arc centered at the specified coordinate in the given image.

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

center_x

x-coordinate of the center.

center_y

y-coordinate of the center.

width

The arc width.

height

The arc height.

start_angle

The arc start angle, in degrees.

end_angle

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().

style

A bitwise OR of the following possibilities:

  1. IMG_ARC_PIE
  2. IMG_ARC_CHORD
  3. IMG_ARC_NOFILL
  4. IMG_ARC_EDGED
IMG_ARC_PIE and IMG_ARC_CHORD are mutually exclusive; IMG_ARC_CHORD just connects the starting and ending angles with a straight line, while IMG_ARC_PIE produces a rounded edge. IMG_ARC_NOFILL indicates that the arc or chord should be outlined, not filled. IMG_ARC_EDGED, used together with IMG_ARC_NOFILL, indicates that the beginning and ending angles should be connected to the center - this is a good way to outline (rather than fill) a 'pie slice'.

Return Values

Returns true on success or false on failure.

Changelog

Version Description
8.0.0 image expects a GdImage instance now; previously, a resource was expected.

Examples

Example #1 Creating a 3D looking pie

<?php

// create image
$image imagecreatetruecolor(100100);

// allocate some colors
$white    imagecolorallocate($image0xFF0xFF0xFF);
$gray     imagecolorallocate($image0xC00xC00xC0);
$darkgray imagecolorallocate($image0x900x900x90);
$navy     imagecolorallocate($image0x000x000x80);
$darknavy imagecolorallocate($image0x000x000x50);
$red      imagecolorallocate($image0xFF0x000x00);
$darkred  imagecolorallocate($image0x900x000x00);

// make the 3D effect
for ($i 60$i 50$i--) {
   
imagefilledarc($image50$i10050045$darknavyIMG_ARC_PIE);
   
imagefilledarc($image50$i100504575 $darkgrayIMG_ARC_PIE);
   
imagefilledarc($image50$i1005075360 $darkredIMG_ARC_PIE);
}

imagefilledarc($image505010050045$navyIMG_ARC_PIE);
imagefilledarc($image5050100504575 $grayIMG_ARC_PIE);
imagefilledarc($image50501005075360 $redIMG_ARC_PIE);


// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

The above example will output something similar to:

Output of example : Creating a 3D looking pie