为什么我在我的GD饼图中看到这个奇怪的线?
问题描述:
为什么我在我的GD饼图中看到这个奇怪的线?为什么我在我的GD饼图中看到这个奇怪的线?
这里的PHP:
<?php
$ratio = $_GET['ratio'];
$height = intval(isset($_GET['size']) ? $_GET['size'] : 200);
$width = intval(isset($_GET['size']) ? $_GET['size'] : 200);
$startDegree = 270;
$ratiodeg = $ratio * 360;
$image = imagecreatetruecolor($width,$height);
imagealphablending($image,false);
imagesavealpha($image,true);
$color = imagecolorallocate($image,127,26,40);
$grey = imagecolorallocate($image,200,200,200);
$transparent = imagecolorallocatealpha($image,255,255,255,127);
imagefilledrectangle($image,0,0,$width,$height,$transparent);
if($ratio > 0){
if($ratio < 1){
imagefilledarc($image,$width/2,$height/2,$width,$height,$ratiodeg + $startDegree,$startDegree,$grey,IMG_ARC_PIE);
}
imagefilledarc($image,$width/2,$height/2,$width,$height,$startDegree,$ratiodeg + $startDegree,$color,IMG_ARC_PIE);
}
else{
imagefilledarc($image,$width/2,$height/2,$width,$height,$startDegree,360 + $startDegree,$grey,IMG_ARC_PIE);
}
imagefilledellipse($image,$width/2,$height/2,$width * 0.95,$height * 0.95,$transparent);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?>
答
我跑你的代码,并得到了这个形象..
这里是我的PHP细节
版本: 5.4.3
GD:捆绑(2.0.34兼容)
你通过了什么比例?我使用了1,4,4.65(圈出了一个有点缺失的圈),但我从来没有这样做过!
该比例是一个浮点数,但我尝试了这些值以及相同的结果。我使用5.2.some没有捆绑GD(至少,我不这么认为 - 我没有捆绑的imageantialias,所以可能不会)。它可能是我的发行版中的错误吗? – iLoch 2012-07-27 05:50:46
创建一个名为phpinfo.php的新php文件,并将其放入它中。然后运行它..它会给你很多有关你的php的细节,你可能希望尽快删除它,虽然它不是你的服务器上最安全的页面! – Dale 2012-07-27 06:31:06