0) { $remainder=$number%16; if ($remainder<10) $hexval=$remainder.$hexval; elseif ($remainder==10) $hexval="a".$hexval; elseif ($remainder==11) $hexval="b".$hexval; elseif ($remainder==12) $hexval="c".$hexval; elseif ($remainder==13) $hexval="d".$hexval; elseif ($remainder==14) $hexval="e".$hexval; elseif ($remainder==15) $hexval="f".$hexval; $number=floor($number/16); } while (strlen ($hexval) < $length) $hexval="0".$hexval; //this is just to add zero's at the beginning to make hexval a certain length return $hexval; } if(isset($_GET ["largura"])) $largura = $_GET ["largura"]; else $largura = 200; if(isset($_GET ["altura"])) $altura = $_GET ["altura"]; else $altura = 200; if(isset($_GET ["partes"])) $partes = $_GET ["partes"]; else $partes = array(10.3,5.4,28.1,36.2,5.6,14.4); $largura_pizza = round(0.75 * $largura, 0); $altura_pizza = round(0.75 * $altura, 0); header ("Content-type: image/png"); $img = imagecreate($largura,$altura); $fundo = imagecolorallocate($img, 255,255,255); $cor1 = imagecolorallocate($img, 0xCC,0xCC,0xCC); imagearc ($img,round($largura/2,0),round($altura/2,0),$largura_pizza,$altura_pizza,0,360,$cor1); $num = count($partes); $inicio = 0; for($i = 1 ; $i <= $num ; $i++) { $final = round ($inicio + 3.6 * $partes [$i]); if($i==$num) $final = 360; $cor_atual = colors ($i); $cor2 = imagecolorallocate($img, hexdec(substr($cor_atual, 0, 2)),hexdec(substr($cor_atual, 2, 2)),hexdec(substr($cor_atual, 4, 2))); ifa ($img,round($largura/2,0),round($altura/2,0),$largura_pizza,$altura_pizza,$inicio,$final,$cor1,$cor2); $inicio = $final; } imagepng ($img); ?>