略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ImagickDraw::setStrokeDashArray

2024-12-22

ImagickDraw::setStrokeDashArray

(PECL imagick 2, PECL imagick 3)

ImagickDraw::setStrokeDashArraySpecifies the pattern of dashes and gaps used to stroke paths

说明

public ImagickDraw::setStrokeDashArray(array $dashArray): bool
警告

本函数还未编写文档,仅有参数列表。

Specifies the pattern of dashes and gaps used to stroke paths. The strokeDashArray represents an array of numbers that specify the lengths of alternating dashes and gaps in pixels. If an odd number of values is provided, then the list of values is repeated to yield an even number of values. To remove an existing dash array, pass a zero number_elements argument and null dash_array. A typical strokeDashArray_ array might contain the members 5 3 2.

参数

dashArray

array of floats

返回值

成功时返回 true

范例

示例 #1 ImagickDraw::setStrokeDashArray() example

<?php
function setStrokeDashArray($strokeColor$fillColor$backgroundColor) {

    
$draw = new \ImagickDraw();

    
$draw->setStrokeColor($strokeColor);
    
$draw->setFillColor($fillColor);
    
$draw->setStrokeWidth(4);

    
$draw->setStrokeDashArray([1010]);
    
$draw->rectangle(10050225175);

    
$draw->setStrokeDashArray([20520555,]);
    
$draw->rectangle(27550400175);

    
$draw->setStrokeDashArray([2052055]);
    
$draw->rectangle(100200225350);

    
$draw->setStrokeDashArray([11112233558813132121343455558989144144233233377377610610987987159715972584258441814181,]);

    
$draw->rectangle(275200400350);

    
$image = new \Imagick();
    
$image->newImage(500400$backgroundColor);
    
$image->setImageFormat("png");
    
$image->drawImage($draw);

    
header("Content-Type: image/png");
    echo 
$image->getImageBlob();
}

?>
add a noteadd a note

User Contributed Notes 2 notes

up
1
KV
3 years ago
To remove the dash and switch back to solid line, provide an array with a null value in it for $dashArray.

->setStrokeDashArray( [null] );
up
1
andrew at ierbsolutions dot co dot uk
13 years ago
Example:

<?php
$base_image
= new Imagick('example.png');
$rect = new ImagickDraw();
$rect->setFillColor(new ImagickPixel("#EEEEEE"));
$rect->setFillOpacity(0);
$rect->setStrokeColor(new ImagickPixel("#FF0000"));
$rect->setStrokeDashArray(array(5,5,5));
$rect->rectangle(10, 10, 100, 100);
$base_image->drawImage($rect);

header('Content-type: image/png');
echo
$base_image->getImage();
exit();
?>

官方地址:https://www.php.net/manual/en/imagickdraw.setstrokedasharray.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3