note 50567 deleted from function.imagefilledarc by tularis
| From: | tularis@php.net | Date: | Sat, 05 Jul 2008 09:59:24 +0000 |
| Subject: | note 50567 deleted from function.imagefilledarc by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141191@lists.php.net to get a copy of this message | ||
Note Submitter: braulio at example dot com
----
He añadido un par de cosillas al ejemplo de "hans at lintoo dot dk", sobre todo el grosor
(thickness) del efecto 3D...
<?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];
}
*/
$data = array( 100, 200, 50, 40); /* datos a mostrar ( menos de 12 valores ) */
$num_data = count ($data);
//Getting ready
$datasum = array_sum($data);
$anglesum[0] = 0;
$angle[0] = 0;
$i = 0;
//Se calcula el comienzo y final de la posición de los ángulos de los elementos
while ($i < $num_data) {
++$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);
*/
// Variables posicion
$cx = 120;
$cy = 100;
$ancho = 100;
$largo = 2 * $ancho; // relación de aspecto
$grosor = 25; // efecto 3D
// make the 3D effect
for ($g = $grosor; $g > 0; $g--) {
$n = 0;
while ($n < $num_data) {
++$n;
$f = $n - 1;
if ($angle[$n] != 0)
imagefilledarc($im, $cx, $cy + $g, $largo, $ancho, $anglesum[$f], $anglesum[$n],
$darkcolor[$f], IMG_ARC_PIE);
}
}
//make the 2d data that sits above the 3deffect
$i = 0;
while ($i < $num_data) {
++$i;
$n = $i - 1;
if ($angle[$i] != 0) {
imagefilledarc($im, $cx, $cy, $largo, $ancho, $anglesum[$n], $anglesum[$i], $randcolor[$n],
IMG_ARC_PIE);
}
}
// flush image
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>