note 45489 added to function.imagefilledarc

From: Date: Thu, 09 Sep 2004 02:09:05 +0000
Subject: note 45489 added to function.imagefilledarc
Groups: php.notes 
Request: Send a blank email to php-notes+get-76265@lists.php.net to get a copy of this message
for nice colors and adapted shadows from amount of values i try: <?php function _errechne_gradzahlen( $werte ) { /* calc degrees */ 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 ); /* the data to display ( real values ) */ $werte = _errechne_gradzahlen( $values ); /* degrees-array */ $width = 200; $height = 200; $half_width = floor( $width / 2 ); $half_height = floor($height / 2); $im = ImageCreateTrueColor( $width, $height ); foreach( $werte as $key => $wert ) { /* get colors and shadows */ $color = _randomcol( $im ); $shadow = $color - 20000; // or brighter shadows take 10000 $colors[] = $color; $shadows[] = $shadow; /* 3D effekt */ for ($i = ($half_height + 10); $i > $half_height; $i--) { imagefilledarc( $im, $half_width, $i, $width, $half_height, $offset, ($offset + $wert), // from, to (degrees) $shadows[$key], IMG_ARC_NOFILL); } $offset = $offset + $wert; } $offset = 0; foreach( $werte as $key => $wert ) { /* an now draw the top */ imagefilledarc( $im, $half_width, $half_width, $width, $half_height, // half sized $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. ---- Manual Page -- http://www.php.net/manual/en/function.imagefilledarc.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45489 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45489&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45489&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76265) next »