note 44177 added to function.imagefilledarc

From: Date: Fri, 16 Jul 2004 19:27:10 +0000
Subject: note 44177 added to function.imagefilledarc
Groups: php.notes 
Request: Send a blank email to php-notes+get-73411@lists.php.net to get a copy of this message
I modificed the code to make a 3d pie from data collected elsewhere.... in this case it was for a statistics page... when testing you can use: enjoy <?php //Making a image 200 x 200 $im = imagecreate (200, 200); //Setting background color $background = imagecolorallocate($im, 226, 226, 226); //Setting colors of elements $randcolor[0] = imagecolorallocate($im, 255, 203, 3); $randcolor[1] = imagecolorallocate($im, 220, 101, 29); $randcolor[2] = imagecolorallocate($im, 189, 24, 51); $randcolor[3] = imagecolorallocate($im, 214, 0, 127); $randcolor[4] = imagecolorallocate($im, 98, 1, 96); $randcolor[5] = imagecolorallocate($im, 0, 62, 136); $randcolor[6] = imagecolorallocate($im, 0, 102, 179); $randcolor[7] = imagecolorallocate($im, 0, 145, 195); $randcolor[8] = imagecolorallocate($im, 0, 115, 106); $randcolor[9] = imagecolorallocate($im, 178, 210, 52); $randcolor[10] = imagecolorallocate($im, 137, 91, 74); $randcolor[11] = imagecolorallocate($im, 82, 56, 47); //Setting the darker alt color to the main color $darkcolor[0] = imagecolorallocate($im, 205, 153, 0); $darkcolor[1] = imagecolorallocate($im, 170, 51, 0); $drakcolor[2] = imagecolorallocate($im, 139, 0, 1); $darkcolor[3] = imagecolorallocate($im, 164, 0, 77); $darkcolor[4] = imagecolorallocate($im, 48, 0, 46); $darkcolor[5] = imagecolorallocate($im, 0, 12, 86); $darkcolor[6] = imagecolorallocate($im, 0, 52, 129); $darkcolor[7] = imagecolorallocate($im, 0, 95, 145); $darkcolor[8] = imagecolorallocate($im, 0, 65, 56); $darkcolor[9] = imagecolorallocate($im, 128, 160, 2); $darkcolor[10] = imagecolorallocate($im, 87, 41, 24); $darkcolor[11] = imagecolorallocate($im, 32, 6, 0); //Getting the data from GET $i = 0; while ($i <= 11) { $data[$i] = $_GET[++$i]; } //Getting ready $datasum = array_sum($data); $anglesum[0] = 0; $angle[0] = 0; $i = 0; //Calc the start and end angle position of the elements while ($i <= 11) { ++$i; $n = $i - 1; $part[$i] = $data[$n] / $datasum; $angle[$i] = floor($part[$i] * 360); $anglesum[$i] = array_sum($angle); } /* //DEBUGGING - only for testing purposes echo "<pre>"; print_r($part); print_r($anglesum); print_r($angle); */ // make the 3D effect $n = 0;$i=0; while ($n <= 11) { ++$n; $f = $n - 1; if ($angle[$n] != 0) { for ($i = 110; $i > 100; $i--) { imagefilledarc($im, 100, $i, 200, 100, $anglesum[$f], $anglesum[$n], $darkcolor[$f], IMG_ARC_PIE); } } } //make the 2d data that sits above the 3deffect $i = 0; while ($i <= 11) { ++$i; $n = $i - 1; if ($angle[$i] != 0) { imagefilledarc($im, 100, 100, 200, 100, $anglesum[$n], $anglesum[$i], $randcolor[$n], IMG_ARC_PIE); } } // flush image header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagefilledarc.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44177 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44177&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44177&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73411) next »