for nice colors and adapted shadows from amount of values i try:
<?php
function _errechne_gradzahlen( $werte ) { foreach( $werte as $wert ) { $sum += $wert; }
foreach( $werte as $wert ) { $gradzahlen[] = 360 * ( $wert / $sum ); }
return $gradzahlen;
}
function _randomcol ( $im ) {
return imagecolorallocate( $im, rand(100, 224), rand(100, 224), rand(128, 224) );
}
$values = array( 100, 200, 50, 100, 43, 32 ); $werte = _errechne_gradzahlen( $values ); $width = 200;
$height = 200;
$half_width = floor( $width / 2 );
$half_height = floor($height / 2);
$im = ImageCreateTrueColor( $width, $height );
foreach( $werte as $key => $wert ) {
$color = _randomcol( $im );
$shadow = $color - 20000; $colors[] = $color;
$shadows[] = $shadow;
for ($i = ($half_height + 10); $i > $half_height; $i--) {
imagefilledarc(
$im,
$half_width, $i,
$width, $half_height,
$offset, ($offset + $wert), $shadows[$key], IMG_ARC_NOFILL);
}
$offset = $offset + $wert;
}
$offset = 0;
foreach( $werte as $key => $wert ) { imagefilledarc(
$im,
$half_width, $half_width,
$width, $half_height, $offset, ($offset + $wert),
$colors[$key], IMG_ARC_PIE);
$offset = $offset + $wert;
}
header( "Content-type: image/png" );
imagepng ( $im );
imagedestroy( $im );
?>
sry for my crab english and the disordered code, i cut and 'translate' it from a class i wrote before.