PHP 中的 imagedashedline() 函数
phpserver side programmingprogramming更新于 2025/7/6 16:07:17
imagedashedline() 函数用于绘制虚线。
语法
imagedashedline( $image , $x1 , $y1 , $x2 , $y2 , $color )
参数
image
使用 imagecreatetruecolor() 创建空白图像。x1
左上角 x 坐标y1
左上角 y 坐标x2
右下角x 坐标y2
右下角 y 坐标color
填充颜色。
返回
函数成功时返回 TRUE,失败时返回 FALSE。
示例
以下是示例:
<?php
$image = imagecreatetruecolor(500, 370);
$bgcolor = imagecolorallocate($image, 70, 90, 120);
imagefill($image, 0, 0, $bgcolor);
$color = imagecolorallocate($image, 90, 220, 175);
imagedashedline($image, 0, 0, 150, 50, $color);
header("Content-type: image/png");
imagepng($image);
?>
输出
输出结果如下:


