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


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

ImagickDraw::setTextAntialias() 函數是 PHP 的內置函數,用於控製文本是否抗鋸齒。默認情況下,文本是抗鋸齒的。

用法:

bool ImagickDraw::setTextAntialias( $antiAlias )

參數:此函數接受單個參數 $antiAlias,用於存儲布爾信號,即 TRUE/FALSE。

返回值:此函數不返回任何值。

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



程序1:


<?php
  
// Create an ImagickDraw object
$draw = new ImagickDraw();
   
// Set the image filled color
$draw->setFillColor('green');
  
// Set the font size
$draw->setFontSize(50);
  
// Set the Text Antialias
$draw->setTextAntialias(false);
  
// Set the text to be added
$draw->annotation(50, 75, "Gfg!");
  
// Create new Imagick object 
$imagick = new Imagick();
  
// Set the image dimensions
$imagick->newImage(500, 160, 'black');
  
// Set the image format
$imagick->setImageFormat("png");
  
// Draw the image
$imagick->drawImage($draw);
header("Content-Type:image/png");
  
// Display the image
echo $imagick->getImageBlob();
?>

輸出:
setTextAntialias

程序2:


<?php
  
// Create an ImagickDraw object
$draw = new ImagickDraw();
  
// Set the image filled color 
$draw->setFillColor('orange');
  
// Set the font size
$draw->setFontSize(50);
  
// Set the TextAntialias function
$draw->setTextAntialias(true);
  
// Set the text to be added
$draw->annotation(5, 75, "Gfg!");
  
// Set the TextAntialias function
$draw->setTextAntialias(false);
  
// Set the text to be added
$draw->annotation(105, 75, "Gfg!");
  
// Create new Imagick object
$imagick = new Imagick();
  
// Set the image dimensions
$imagick->newImage(300, 160, 'green');
  
// Set the image format
$imagick->setImageFormat("png");
  
// Draw the image
$imagick->drawImage($draw);
header("Content-Type:image/png");
  
// Display the image
echo $imagick->getImageBlob();
?>

輸出:
setTextAntialias

參考: http://php.net/manual/en/imagickdraw.settextantialias.php




相關用法


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