To remove the dash and switch back to solid line, provide an array with a null value in it for $dashArray.
->setStrokeDashArray( [null] );
(PECL imagick 2.0.0)
ImagickDraw::setStrokeDashArray — Specifies the pattern of dashes and gaps used to stroke paths
$dashArray
)이 함수는 현재 문서화 되어있지 않습니다; 인수 목록만을 제공합니다.
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
를 반환합니다.
Example #1 ImagickDraw::setStrokeDashArray()
<?php
function setStrokeDashArray($strokeColor, $fillColor, $backgroundColor) {
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(4);
$draw->setStrokeDashArray([10, 10]);
$draw->rectangle(100, 50, 225, 175);
$draw->setStrokeDashArray([20, 5, 20, 5, 5, 5,]);
$draw->rectangle(275, 50, 400, 175);
$draw->setStrokeDashArray([20, 5, 20, 5, 5]);
$draw->rectangle(100, 200, 225, 350);
$draw->setStrokeDashArray([1, 1, 1, 1, 2, 2, 3, 3, 5, 5, 8, 8, 13, 13, 21, 21, 34, 34, 55, 55, 89, 89, 144, 144, 233, 233, 377, 377, 610, 610, 987, 987, 1597, 1597, 2584, 2584, 4181, 4181,]);
$draw->rectangle(275, 200, 400, 350);
$image = new \Imagick();
$image->newImage(500, 400, $backgroundColor);
$image->setImageFormat("png");
$image->drawImage($draw);
header("Content-Type: image/png");
echo $image->getImageBlob();
}
?>
To remove the dash and switch back to solid line, provide an array with a null value in it for $dashArray.
->setStrokeDashArray( [null] );
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();
?>