首页 > php画圆设置线宽失败

php画圆设置线宽失败

参照官网代码设置矩形线宽:

<?php
// Create a 200x100 image
$im = imagecreatetruecolor(200, 100);
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

// Set the background to be white
imagefilledrectangle($im, 0, 0, 299, 99, $white);

// Set the line thickness to 5
imagesetthickness($im, 5);

// Draw the rectangle
imagerectangle($im, 14, 14, 185, 85, $black);

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

亲测有效。
但是我现在要画一个圆,把矩形

imagerectangle($im, 14, 14, 185, 85, $black);

修改成

imageellipse($im, 14, 14, 185, 85, $black);

发现圆形线宽还是很细。
手册上讲imagesetthickness方法是支持椭圆的,为什么我测试不行呢?

注:我的gd版本是2.0.32,php版本5.3.3,IE、Chrome都不行。


经鉴定这是一个BUG,各种都实现不了,如果你非要做,给你三个方案:
1、使用imagefilledellipse先画一个大的黑色,再画一个小的白色
2、使用imagearc画一个0到359的弧线,再画一个359到360的弧线
3、使用imageellipse画5次

【热门文章】
【热门文章】