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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。