当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP ImagickDraw skewX()用法及代码示例


ImagickDraw::skewX()函数是PHP中的一个内置函数,用于在水平方向倾斜当前坐标系。

用法:

bool ImagickDraw::skewX( $degrees )

参数:此函数接受单个参数$degrees,该参数用于保存倾斜度。


返回值:该函数不返回任何值。

以下示例程序旨在说明PHP中的ImagickDraw::skewX()函数:

程序1:

<?php 
  
// require_once('path/vendor/autoload.php'); 
   
// Create an ImagickDraw object to draw into. 
$draw = new ImagickDraw(); 
  
// Set the image filled color 
$draw->setFillColor('blue'); 
$points = [['x' => 40 * 5, 'y' => 10 * 5],  
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
             
// Draw the polygon 
$draw->polygon($points); 
  
// Set the image filled color 
$draw->setFillColor('red'); 
$draw->skewX(-60); 
$points = [['x' => 40 * 5, 'y' => 10 * 5],  
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
             
// Draw the polygon            
$draw->polygon($points); 
   
// Set the image filled color 
$draw->setFillColor('green'); 
$draw->skewX(30); 
$points = [['x' => 40 * 5, 'y' => 10 * 5],  
           ['x' => 70 * 5, 'y' => 50 * 5],  
           ['x' => 60 * 5, 'y' => 15 * 5], ]; 
             
// Draw the polygon            
$draw->polygon($points); 
  
// Create new Imagick object 
$image = new Imagick(); 
$image->newImage(500, 500, 'white'); 
  
// Set the image format 
$image->setImageFormat("png"); 
    
// Draw the image 
$image->drawImage($draw); 
    
header("Content-Type: image/png"); 
  
// Display the image 
echo $image->getImageBlob(); 
?>

输出:
skewX

程序2:

<?php 
  
// require_once('path/vendor/autoload.php'); 
   
// Create an ImagickDraw object 
$draw = new ImagickDraw(); 
  
// Set the stroke color 
$draw->setStrokeColor('black'); 
  
// Set the filled color 
$draw->setFillColor('red'); 
  
// Draw the circle 
$draw->circle(250, 250, 100, 150);  
   
// Set the filled color 
$draw->setFillColor('green'); 
  
// Set the skew of X 
$draw->skewX(30); 
  
// Draw the circle 
$draw->circle(250, 250, 100, 150);  
   
// Set the filled color 
$draw->setFillColor('yellow'); 
  
// Set the skew of X 
$draw->skewX(30); 
  
// Draw the circle 
$draw->circle(250, 250, 100, 150);  
   
// Create new imagick object 
$image = new Imagick(); 
  
// Create new image of given size 
$image->newImage(900, 600, 'white'); 
  
// Set the image format 
$image->setImageFormat("png"); 
  
// Draw the image 
$image->drawImage($draw); 
    
header("Content-Type: image/png"); 
  
// Display the output image 
echo $image->getImageBlob(); 
?>

输出:
skewX

参考: http://php.net/manual/en/imagickdraw.skewx.php



相关用法


注:本文由纯净天空筛选整理自sarthak_ishu11大神的英文原创作品 PHP | ImagickDraw skewX() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。