PHP 中的 imagedashedline() 函式


imagedashedline() 函式繪製虛線。

語法

imagedashedline( $image , $x1 , $y1 , $x2 , $y2 , $color )

引數

  • 影像 
    使用 imagecreatetruecolor() 建立空白影像。

  • x1 
    左上角 x 座標

  • y1 
    左上角 y 座標

  • x2 
    右下角 x 座標

  • y2 
    右下角 y 座標

  • 顏色 
    填充顏色。

返回值

成功時函式返回 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);
?>

輸出

以下為輸出

更新於: 31-12-2019

61 已檢視

開啟你的 職業生涯

透過完成課程取得認證

開始
廣告
© . All rights reserved.