首页 > 文章列表 > PHP中的imagedashedline()函数

PHP中的imagedashedline()函数

php 函数 imagedashedline()
228 2023-09-09

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);
?>

输出

以下是输出:

PHP中的imagedashedline()函数