PHP/Graphics Image/imagefilledarc
Creating a Pie Graph Using imagefilledarc()
<?php
define("WIDTH", 200);
define("HEIGHT", 200);
$piegraph_data = array (10, 5, 20, 40, 10, 15);
$img = imagecreate(WIDTH, HEIGHT);
$background = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($img, 0, 0, 0);
$center_x = (int)WIDTH/2;
$center_y = (int)HEIGHT/2;
imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $black);
$last_angle = 0;
$percentage = 30;
$arclen = (360 * $percentage) / 100;
imagefilledarc($img,$center_x,$center_y,WIDTH-20,HEIGHT-20,$last_angle,($last_angle + $arclen),$black,IMG_ARC_EDGED | IMG_ARC_NOFILL);
header("Content-Type: image/png");
imagepng($img);
?>
Ellipses and circles
IMG_ARC_PIE draws a filled wedge shape with a curved edge
IMG_ARC_CHORD draws a straight line between the starting and ending angles
IMG_ARC_NOFILL draws the outside edge line without drawing the two lines toward the center of the arc
IMG_ARC_EDGED draws an unfilled wedge shape with a curved edge
<?
imagefilledarc($image, 200, 150, 200, 200, 345, 15, $green,IMG_ARC_CHORD | IMG_ARC_NOFILL);
imagefilledarc($image, 200, 150, 200, 200, 345, 15, $green,IMG_ARC_EDGED | IMG_ARC_NOFILL);
?>
Using imagefilledarc()
<?php
define("WIDTH", 300);
define("HEIGHT", 300);
$img = imagecreate(WIDTH,HEIGHT);
$bg = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($img, 0, 0, 0);
$center_x = (int)WIDTH/2;
$center_y = (int)HEIGHT/2;
imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $black);
imagefilledarc($img,
$center_x,
$center_y,
WIDTH/2,
HEIGHT/2,
0,
90,
$black,
IMG_ARC_PIE);
header("Content-Type: image/png");
imagepng($img);
?>