ImagickDraw::rectangle()函數是PHP的Imagick庫中的一個內置函數,用於繪製矩形。
用法:
bool ImagickDraw::rectangle( $x1, $y1, $x2, $y2 )
參數:該函數接受上述和以下所述的四個參數:
- $x1:此參數采用左上角的x坐標值。
- $y1:此參數采用左上角的y坐標值。
- $x2:此參數采用右下角的x坐標值。
- $y2:此參數采用右下角的y坐標值。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的ImagickDraw rectangle()函數:
程序:
<?php 
// require_once('vendor/autoload.php'); 
  
// Create ImagickDraw object 
$draw = new \ImagickDraw(); 
$draw->setStrokeColor('Green'); 
$draw->setFillColor('Red'); 
$draw->setStrokeWidth(7); 
$draw->rectangle(40, 30, 200, 260); 
  
// Create an image object which the draw 
// commands can be rendered into 
$image = new \Imagick(); 
$image->newImage(300, 300, 'White'); 
$image->setImageFormat("png"); 
  
// Render the draw commands in the ImagickDraw object  
// into the image. 
      
$image->drawImage($draw); 
  
// Send the image to the browser 
header("Content-Type: image/png"); 
echo $image->getImageBlob(); 
?>輸出:

參考: http://php.net/manual/en/imagickdraw.rectangle.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw ellipse()用法及代碼示例
- PHP ImagickDraw setStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw getTextAntialias()用法及代碼示例
- PHP ImagickDraw getStrokeDashOffset()用法及代碼示例
- PHP ImagickDraw composite()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setFont()用法及代碼示例
- PHP ImagickDraw setFillColor()用法及代碼示例
- PHP ImagickDraw setStrokeAlpha()用法及代碼示例
- PHP ImagickDraw pathLineToHorizontalAbsolute()用法及代碼示例
- PHP ImagickDraw pathLineToAbsolute()用法及代碼示例
- PHP ImagickDraw setFontStyle()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw rectangle() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
