PHP 中的 imagefilledrectangle() 函式


imagefilledrectangle() 函式會繪製一個填充的矩形。

語法

imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color )

引數

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

  • x1
    點 1 的 x 座標。

  • y1 
    點 1 的 y 座標。

  • x2
     點 2 的 x 座標。

  • y2 
    點 2 的 y 座標。

  • color 
    填充顏色。

返回值

imagefilledrectangle() 函式在成功時返回 TRUE,失敗時返回 FALSE。

示例

以下是一個示例

<?php
   // Create an image
   $img = imagecreatetruecolor(500, 300);
   $color = imagecolorallocate($img, 0, 128, 128);
   imagefilledrectangle($img, 30, 30, 470, 270, $color);
   header("Content-type: image/png");
   imagepng($img);
   imagedestroy($img);
?>

輸出

以下為輸出

更新於:31-Dec-2019

860 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.