當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP ImagickDraw roundRectangle()用法及代碼示例

ImagickDraw::roundRectangle()函數是PHP的Imagick庫中的一個內置函數,用於繪製圓角矩形。

用法:

bool ImagickDraw::roundRectangle( $x1, $y1, $x2, $y2, $rx, $ry )

參數:該函數接受上述和以下所述的六個參數:


  • $x1:此參數采用左上角的x坐標值。
  • $y1:此參數采用左上角的y坐標值。
  • $x2:此參數采用右下角的x坐標值。
  • $y2:此參數采用右下角的y坐標值。
  • $rx:此參數采用x舍入的值。
  • $ry:此參數采用y舍入的值。

返回值:成功時此函數返回TRUE。

以下示例程序旨在說明PHP中的ImagickDraw::roundRectangle()函數:

程序:

<?php 
// require_once('vendor/autoload.php'); 
  
// Create ImagickDraw object 
$draw = new \ImagickDraw(); 
      
$draw->setStrokeColor('Green'); 
$draw->setFillColor('Red'); 
$draw->setStrokeWidth(7); 
  
$draw->roundRectangle(40, 30, 250, 260, 40, 80); 
  
// 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.roundrectangle.php



相關用法


注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 PHP | ImagickDraw roundRectangle() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。