本文整理汇总了PHP中ImagickDraw::setStrokeDashArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setStrokeDashArray方法的具体用法?PHP ImagickDraw::setStrokeDashArray怎么用?PHP ImagickDraw::setStrokeDashArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setStrokeDashArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* Draws an ellipse on the handle
*
* @param ImageMagick-object $handle The handle on which the ellipse is drawn
* @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
*/
public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawEllipse $ellipseObject)
{
$draw = new ImagickDraw();
$strokeColor = (string) $ellipseObject->getStrokeColor();
$strokeAlpha = $ellipseObject->getStrokeAlpha() * 0.01;
$draw->setStrokeColor($strokeColor);
$draw->setStrokeOpacity($strokeAlpha);
$draw->setStrokeWidth($ellipseObject->getStrokeWidth());
$strokeDashArray = $ellipseObject->getStrokeDashPattern();
if (count($strokeDashArray) > 0) {
$draw->setStrokeDashArray($strokeDashArray);
}
$draw->setStrokeDashOffset($ellipseObject->getStrokeDashOffset());
if ($ellipseObject->filled()) {
$fillColor = (string) $ellipseObject->getFillColor();
$draw->setFillColor($fillColor);
$draw->setFillOpacity($ellipseObject->getFillAlpha() * 0.01);
} else {
$draw->setFillOpacity(0);
}
$width = $ellipseObject->getWidth();
$height = $ellipseObject->getHeight();
$x = $ellipseObject->getLocation()->getX();
$y = $ellipseObject->getLocation()->getY();
$draw->ellipse($x, $y, $width / 2, $height / 2, 0, 360);
$adapter->getHandle()->drawImage($draw);
}
示例2: perform
/**
* Draws a polygon on the handle
*
* @param ImageMagick-object $handle The handle on which the polygon is drawn
* @param Zend_Image_Action_DrawPolygon $polygon The object that with all info
*/
public function perform($handle, Zend_Image_Action_DrawPolygon $polygon) { // As of ZF2.0 / PHP5.3, this can be made static.
$points = $this->_parsePoints($polygon->getPoints());
if ($polygon->isClosed()){
//add first point at the end to close
$points[count($points)] = $points[0];
}
$draw = new ImagickDraw();
$draw->setStrokeColor('#' . $polygon->getStrokeColor()->getHex());
$draw->setStrokeOpacity($polygon->getStrokeAlpha()/100);
$draw->setStrokeWidth($polygon->getStrokeWidth());
$strokeDashArray = $polygon->getStrokeDashPattern();
if (count($strokeDashArray) > 0){
$draw->setStrokeDashArray($strokeDashArray);
}
$draw->setStrokeDashOffset($polygon->getStrokeDashOffset());
if($polygon->isFilled()) {
$fillColor = $polygon->getFillColor();
$draw->setFillColor('#' . $fillColor->getHex());
$draw->polygon($points);
} else {
//Use transparent fill to render unfilled
$draw->setFillOpacity(0);
$draw->polyline($points);
}
$handle->getHandle()->drawImage($draw);
}
示例3: dashedLine
/**
* Draw a dashed line.
*
* @param integer $x0 The x co-ordinate of the start.
* @param integer $y0 The y co-ordinate of the start.
* @param integer $x1 The x co-ordinate of the end.
* @param integer $y1 The y co-ordinate of the end.
* @param string $color The line color.
* @param string $width The width of the line.
* @param integer $dash_length The length of a dash on the dashed line
* @param integer $dash_space The length of a space in the dashed line
*/
public function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2)
{
$draw = new ImagickDraw();
$draw->setStrokeColor(new ImagickPixel($color));
$draw->setStrokeWidth($width);
$draw->setStrokeDashArray(array($dash_length, $dash_space));
$draw->line($x0, $y0, $x1, $y1);
try {
$res = $this->_imagick->drawImage($draw);
} catch (ImageException $e) {
throw new Horde_Image_Exception($e);
}
$draw->destroy();
}
示例4: setStrokeDashOffset
function setStrokeDashOffset($strokeColor, $fillColor, $backgroundColor)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(4);
$draw->setStrokeDashArray([20, 20]);
$draw->setStrokeDashOffset(0);
$draw->rectangle(100, 50, 225, 175);
//Start the dash effect halfway through the solid portion
$draw->setStrokeDashOffset(10);
$draw->rectangle(275, 50, 400, 175);
//Start the dash effect on the space portion
$draw->setStrokeDashOffset(20);
$draw->rectangle(100, 200, 225, 350);
$draw->setStrokeDashOffset(5);
$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();
}
示例5: ImagickPixel
// fill
$draw->setFillColor('yellow');
var_dump($draw->getFillColor()->getColor());
$draw->setFillOpacity(0.5);
printf("%.2f\n", $draw->getFillOpacity());
$draw->setFillRule(Imagick::FILLRULE_NONZERO);
var_dump($draw->getClipRule() === Imagick::FILLRULE_NONZERO);
// gravity
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);
var_dump($draw->getGravity() === Imagick::GRAVITY_SOUTHEAST);
// stroke
$draw->setStrokeAntialias(false);
var_dump($draw->getStrokeAntialias());
$draw->setStrokeColor(new ImagickPixel('#F02B88'));
var_dump($draw->getStrokeColor()->getColor());
$draw->setStrokeDashArray(array(1, 2, 3));
var_dump($draw->getStrokeDashArray());
$draw->setStrokeDashOffset(-1);
var_dump($draw->getStrokeDashOffset());
$draw->setStrokeLineCap(Imagick::LINECAP_SQUARE);
var_dump($draw->getStrokeLineCap() === Imagick::LINECAP_SQUARE);
$draw->setStrokeLineJoin(Imagick::LINEJOIN_BEVEL);
var_dump($draw->getStrokeLineJoin() === Imagick::LINEJOIN_BEVEL);
$draw->setStrokeMiterLimit(3);
var_dump($draw->getStrokeMiterLimit());
$draw->setStrokeOpacity(0.9);
printf("%.2f\n", $draw->getStrokeOpacity());
$draw->setStrokeWidth(1.2);
printf("%.2f\n", $draw->getStrokeWidth());
// text
$draw->setTextAlignment(Imagick::ALIGN_CENTER);