ImagickDraw::setFillPatternURL()函數是PHP中的內置函數,用於設置URL以用作填充對象的填充模式。該URL實際上是模式的唯一名稱,該名稱前帶有“#”。
用法:
bool ImagickDraw::setFillPatternURL( string $fill_url )
參數:該函數接受單個參數$fill_url,該參數保存URL。
返回值:成功時此函數返回TRUE。
以下示例程序旨在說明PHP中的ImagickDraw::setFillPatternURL()函數:
程序1:
<?php
// Create a new imagick object
$imagick = new Imagick();
// Create a image on imagick object
$imagick->newImage(800, 250, 'black');
// Create a new imagickDraw object
$draw = new ImagickDraw();
// Push the pattern
$draw->pushPattern("MyPattern", 0, 0, 50, 50);
$color = ['blue', 'black', 'cyan'];
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$draw->setFillColor($color[$y % 3]);
$draw->circle($x, $y + 80, $x % 2, $y);
}
}
// Pop the pattern
$draw->popPattern();
// Set the fill Opacity
$draw->setFillOpacity(0);
// Set the fill pattern URL
$draw->setFillPatternURL('#MyPattern');
// Draw a rectangle on which pattern is made
$draw->rectangle(0, 0, 400, 400);
// Render the draw commands
$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
$imagick->newImage(800, 250, 'white');
// Create a new imagickDraw object
$draw = new ImagickDraw();
// Push the pattern
$draw->pushPattern("MyPattern", 0, 0, 50, 50);
for ($x = 0; $x < 50; $x += 10) {
for ($y = 0; $y < 50; $y += 5) {
$draw->rectangle($x, $y + 80, $x % 2, $y);
}
}
// Pop the pattern
$draw->popPattern();
// Set the fill Opacity
$draw->setFillOpacity(0);
// Set the fill pattern URL
$draw->setFillPatternURL('#MyPattern');
// Draw a rectangle on which pattern is made
$draw->rectangle(0, 0, 900, 900);
// Render the draw commands
$imagick->drawImage($draw);
// Show the output
$imagick->setImageFormat('png');
header("Content-Type:image/png");
echo $imagick->getImageBlob();
?>
輸出:
參考: https://www.php.net/manual/en/imagickdraw.setfillpatternurl.php
相關用法
- PHP ImagickDraw arc()用法及代碼示例
- PHP ImagickDraw pop()用法及代碼示例
- PHP ImagickDraw pathCurveToQuadraticBezierSmoothAbsolute()用法及代碼示例
- PHP ImagickDraw setStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw getStrokeMiterLimit()用法及代碼示例
- PHP ImagickDraw setFontWeight()用法及代碼示例
- PHP ImagickDraw setFontSize()用法及代碼示例
- PHP ImagickDraw pathStart()用法及代碼示例
- PHP ImagickDraw getStrokeLineJoin()用法及代碼示例
- PHP ImagickDraw getStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setStrokeLineCap()用法及代碼示例
- PHP ImagickDraw setTextAntialias()用法及代碼示例
- PHP ImagickDraw setTextDecoration()用法及代碼示例
- PHP ImagickDraw setTextUnderColor()用法及代碼示例
- PHP ImagickDraw polygon()用法及代碼示例
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | ImagickDraw setFillPatternURL() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。