ImagickDraw::affine()函數是PHP中的內置函數,用於調整當前仿射變換矩陣。
用法:
bool ImagickDraw::affine( array $affine )
參數:該函數接受單個參數$affine,該參數保存包含仿射矩陣參數的數組。
返回值:成功時此函數返回TRUE。
異常:該函數在錯誤時引發ImagickException。
下麵給出的程序說明了PHP中的ImagickDraw::affine()函數:
程序1:
<?php
// Create a new Imagick object
$imagick = new Imagick();
// Create a image on imagick object with
// green background
$imagick->newImage(800, 250, 'green');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Translate the object
$draw->translate(100, 100);
// Apply the affine() function
$draw->affine(array("sx" => 7, "sy" => 1,
"rx" => 9, "ry" => 0,
"tx" => 200, "ty" => 0));
// Draw a rectangle
$draw->rectangle(-50, -50, 50, 50);
// Render the draw commands in the ImagickDraw object
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat("png");
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
程序2:
<?php
//Create a new Imagick object
$imagick = new Imagick();
// Create a image on imagick object with
// purple background
$imagick->newImage(800, 250, 'purple');
// Create a new ImagickDraw object
$draw = new ImagickDraw();
// Translate the object
$draw->translate(100, 100);
// Apply the affine() function
$draw->affine(array("sx" => 2, "sy" => 1,
"rx" => 0, "ry" => 0,
"tx" => 0, "ty" => 0));
// Draw a rectangle
$draw->rectangle(0, -50, 50, 50);
// Draw a rectangle
$draw->rectangle(100, 50, 150, 100);
// Draw a rectangle
$draw->rectangle(200, -10, 250, 90);
// Render the draw commands in the ImagickDraw object
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat("png");
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagickdraw.affine.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setTextInterwordSpacing()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw getStrokeAntialias()用法及代碼示例
- PHP ImagickDraw setTextAntialias()用法及代碼示例
- PHP ImagickDraw setTextDecoration()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
- PHP ImagickDraw roundRectangle()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw affine() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。