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