0

我在画布上绘制了一些框,但 imagedashedline 似乎存在问题。除了线条不水平的情况外,虚线似乎是不可见的。关于什么是错的任何想法?

示例代码

$width = 204;
$height = 317;

$canvas = imagecreate($width, $height);

$white = imagecolorallocate($canvas, 255, 2555, 255);
$black = imagecolorallocate($canvas, 0, 0, 0);

$topLeft     = 2;
$topRight    = 2;

$bottomLeft  = $width-2;
$bottomRight = $height-2;

imagesetthickness($canvas, 1);

// parallel line, solid
imageline($canvas, 0, 101, 204, 101, $black);

// parallel line, should be dashed, fail
imagedashedline($canvas, 0, 121, 204, 121, $black);

// parallel line should be dashed, works
imagedashedline($canvas, 0, 0, 204, 305, $black);

imagejpeg($canvas,'dashes.jpg');
imagedestroy($canvas)

输出

示例输出

4

1 回答 1

2

See comments on imagedashedline(). Also, it's deprecated, but you can use combination of imagesetstyle() and imageline() instead.

于 2013-10-11T15:29:20.107 回答