牛牛在线工具

imagedashedline()

收录 8868 个 PHP 函数,含用途说明与用法示例。

imagedashedline()

在图像资源中绘制一条虚线

函数名:imagedashedline() 适用版本:PHP 4, PHP 5, PHP 7 用法:imagedashedline() 函数用于在图像资源中绘制一条虚线。 语法:bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) 参数: $image:图像资源,由 imagecreatetruecolor() 或 imagecreate() 创建。 $x1:起始点的 x 坐标。 $y1:起始点的 y 坐标。 $x2:结束点的 x 坐标。 $y2:结束点的 y 坐标。 $color:虚线的颜色,由 imagecolorallocate() 创建。 返回值:成功时返回 true,失败时返回 false。 示例: // 创建一个 200x200 的白色画布 $image = imagecreatetruecolor(200, 200); $white = imagecolorallocate($image, 255, 255, 255); imagefilledrectangle($image, 0, 0, 199, 199, $white); // 绘制一条红色虚线 $red = imagecolorallocate($image, 255, 0, 0); imagedashedline($image, 50, 50, 150, 150, $red); // 输出图像到浏览器 header('Content-Type: image/png'); imagepng($image); imagedestroy($image); 以上示例创建了一个200x200的白色画布,并在画布上绘制了一条起始点为(50, 50)、结束点为(150, 150)的红色虚线。最后将图像输出到浏览器并销毁图像资源。