PHP stroke,PHP ImagickDraw getStrokeDashArray()用法及代码示例

ImagickDraw::getStrokeDashArray()函数是PHP中的一个内置函数,用于获取一个数组,该数组表示用于绘制路径的虚线和间隙的模式。

用法:

array ImagickDraw::getStrokeDashArray( void )

参数:此功能不接受任何参数。

返回值:此函数成功返回包含笔划破折号的数组,如果未设置,则返回空数组。

以下示例程序旨在说明PHP中的ImagickDraw::getStrokeDashArray()函数:

示例1:

// Create a new ImagickDraw object

$draw = new ImagickDraw();

// Get the stroke dash array

$array = $draw->getStrokeDashArray();

print("

".print_r($array, true)."
");

?>

输出:

Array // Empty array which is the default value

(

)

示例2:

// Create a new ImagickDraw object

$draw = new ImagickDraw();

// Set the stroke dash array

$draw->setStrokeDashArray([20, 5, 20, 5, 5, 5, ]);

// Get the stroke dash array

$array = $draw->getStrokeDashArray();

print("

".print_r($array, true)."
");

?>

输出:

Array

(

[0] => 20

[1] => 5

[2] => 20

[3] => 5

[4] => 5

[5] => 5

)

示例3:

// Create a new ImagickDraw object

$draw = new ImagickDraw();

// 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();

// Set the fill color

$draw->setFillColor('black');

// Set the color of stroke

$draw->setStrokeColor('red');

// Set the font size

$draw->setFontSize(15);

// Draw a rectangle

$draw->rectangle(100, 50, 225, 175);

// Annotate a text

$draw->annotation(50, 200, 'The strokeDashArray here is default');

// Set the stroke dash array

$draw->setStrokeDashArray([20, 5, 19, 15, 5, 15, ]);

// Draw a rectangle

$draw->rectangle(500, 50, 625, 175);

// Get the stroke dash array

$strokeDashArray = $draw->getStrokeDashArray();

// Annotate a text

$draw->annotation(450, 200, 'The strokeDashArray here is '

. implode(" ", $strokeDashArray));

// Render the draw commands

$imagick->drawImage($draw);

// Show the output

$imagick->setImageFormat('png');

header("Content-Type: image/png");

echo $imagick->getImageBlob();

?>

输出:

ff4a251165e06acf81c5838730e5f3c9.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值