note 17231 added to function.imagearc
| From: | arve at skogvold dot as | Date: | Fri, 30 Nov 2001 18:04:31 +0000 |
| Subject: | note 17231 added to function.imagearc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-21485@lists.php.net to get a copy of this message | ||
I found a better way for drawing a pie chart:
header ("Content-type: image/png");
$diameter = 100;
$radius = $diameter / 2;
$centerX = $radius;
$centerY = $radius;
$im = @ImageCreate ($diameter, $diameter)
or die ("Cannot Initialize new GD image stream");
$background = ImageColorAllocate ($im, 0, 0, 0);
$red = ImageColorAllocate ($im, 176, 0, 0);
function fill_arc($start, $end, $color) {
global $diameter, $centerX, $centerY, $im, $radius;
imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $radius, $centerY +
sin(deg2rad($start)) * $radius, $color);
imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $radius, $centerY +
sin(deg2rad($end)) * $radius, $color);
imagefill ($im,$centerX + $radius * 0.5 *cos(deg2rad($start+($end-$start)/2)), $centerY + $radius *
0.5 * sin(deg2rad($start+($end-$start)/2)), $color);
}
fill_arc(0,30,$red);
// Will make a red filled arc, starting at 0 degrees, ending at 30 degrees
ImagePng ($im);
--
http://www.php.net/manual/en/function.imagearc.php
http://master.php.net/manage/user-notes.php?action=edit+17231
http://master.php.net/manage/user-notes.php?action=delete+17231
http://master.php.net/manage/user-notes.php?action=reject+17231