首頁  >  文章  >  後端開發  >  在PHP中的imagefilledrectangle()函數

在PHP中的imagefilledrectangle()函數

PHPz
PHPz轉載
2023-08-30 09:05:061071瀏覽

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

輸出

#以下是輸出結果:

在PHP中的imagefilledrectangle()函數##

以上是在PHP中的imagefilledrectangle()函數的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除