📜  PHP | imagickdraw skewy()函数

📅  最后修改于: 2022-05-13 01:56:55.442000             🧑  作者: Mango

PHP | imagickdraw skewy()函数

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

句法:

bool ImagickDraw::skewY( $degrees )

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

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

下面的程序说明了PHP中的ImagickDraw::skewY()函数

方案一:

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->skewY(-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->skewY(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();
   
// Set the image dimensions
$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();
?>

输出:
偏斜

方案二:

setStrokeColor('black');
   
// Set the image filled color
$draw->setFillColor('red');
   
// Draw the circle
$draw->circle(250, 250, 100, 150); 
   
// Set the image filled color
$draw->setFillColor('green');
$draw->skewY(-30);
   
// Draw the circle
$draw->circle(250, 250, 100, 150); 
   
// Set the image filled color
$draw->setFillColor('yellow');
$draw->skewY(-60);
   
// Draw the circle
$draw->circle(250, 250, 100, 150); 
   
// Create new Imagick object 
$image = new Imagick();
   
// Set the image dimensions
$image->newImage(700, 700, '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();
?>

输出:
偏斜

参考: http: PHP。 PHP