本文整理汇总了PHP中ImagickDraw::setStrokeWidth方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setStrokeWidth方法的具体用法?PHP ImagickDraw::setStrokeWidth怎么用?PHP ImagickDraw::setStrokeWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setStrokeWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderImage
public function renderImage()
{
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
//http://www.imagemagick.org/Usage/compose/#compose_terms
$draw->setStrokeColor($darkColor);
$draw->setFillColor('white');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($darkColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->setFillColor('none');
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->annotation(50, 180, "Lorem Ipsum!");
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
$draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 300, "SteelBlue2");
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例2: 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);
}
示例3: 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);
}
示例4: ImagickDraw
function __construct()
{
$draw = new ImagickDraw();
$draw->setFillColor('#B42AAF');
$draw->setStrokeColor('black');
$draw->setStrokeWidth(1);
$this->draw = $draw;
}
示例5: drawLine
/**
* Draw line between points
* Нарисовать линии между указанными точками
* @param int $sx
* @param int $sy
* @param int $ex
* @param int $ey
*/
public function drawLine($sx, $sy, $ex, $ey)
{
$draw = new \ImagickDraw();
$draw->setStrokeColor($this->black);
$draw->setStrokeWidth(1);
$draw->line($sx, $sy, $ex, $ey);
$this->drawImage($draw);
}
示例6: analyzeImage
/**
* @param \Imagick $imagick
* @param int $graphWidth
* @param int $graphHeight
*/
public static function analyzeImage(\Imagick $imagick, $graphWidth = 255, $graphHeight = 127)
{
$sampleHeight = 20;
$border = 2;
$imagick->transposeImage();
$imagick->scaleImage($graphWidth, $sampleHeight);
$imageIterator = new \ImagickPixelIterator($imagick);
$luminosityArray = [];
foreach ($imageIterator as $row => $pixels) {
/* Loop through pixel rows */
foreach ($pixels as $column => $pixel) {
/* Loop through the pixels in the row (columns) */
/** @var $pixel \ImagickPixel */
if (false) {
$color = $pixel->getColor();
$luminosityArray[] = $color['r'];
} else {
$hsl = $pixel->getHSL();
$luminosityArray[] = $hsl['luminosity'];
}
}
/* Sync the iterator, this is important to do on each iteration */
$imageIterator->syncIterator();
break;
}
$draw = new \ImagickDraw();
$strokeColor = new \ImagickPixel('red');
$fillColor = new \ImagickPixel('red');
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(0);
$draw->setFontSize(72);
$draw->setStrokeAntiAlias(true);
$previous = false;
$x = 0;
foreach ($luminosityArray as $luminosity) {
$pos = $graphHeight - 1 - $luminosity * ($graphHeight - 1);
if ($previous !== false) {
/** @var $previous int */
//printf ( "%d, %d, %d, %d <br/>\n" , $x - 1, $previous, $x, $pos);
$draw->line($x - 1, $previous, $x, $pos);
}
$x += 1;
$previous = $pos;
}
$plot = new \Imagick();
$plot->newImage($graphWidth, $graphHeight, 'white');
$plot->drawImage($draw);
$outputImage = new \Imagick();
$outputImage->newImage($graphWidth, $graphHeight + $sampleHeight, 'white');
$outputImage->compositeimage($plot, \Imagick::COMPOSITE_ATOP, 0, 0);
$outputImage->compositeimage($imagick, \Imagick::COMPOSITE_ATOP, 0, $graphHeight);
$outputImage->borderimage('black', $border, $border);
$outputImage->setImageFormat("png");
App::cachingHeader("Content-Type: image/png");
echo $outputImage;
}
示例7: applyToImage
/**
* Draw current instance of line to given endpoint on given image
*
* @param Image $image
* @param integer $x
* @param integer $y
* @return boolean
*/
public function applyToImage(Image $image, $x = 0, $y = 0)
{
$line = new \ImagickDraw();
$color = new Color($this->color);
$line->setStrokeColor($color->getPixel());
$line->setStrokeWidth($this->width);
$line->line($this->x, $this->y, $x, $y);
$image->getCore()->drawImage($line);
return true;
}
示例8: perform
/**
* Draw a line on the image, returns the GD-handle
*
* @param Zend_Image_Adapter_ImageMagick image resource $handle Image to work on
* @param Zend_Image_Action_DrawLine $lineObject The object containing all settings needed for drawing a line.
* @return void
*/
public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawLine $lineObject)
{
$handle = $adapter->getHandle();
$draw = new ImagickDraw();
$draw->setStrokeWidth($lineObject->getStrokeWidth());
$color = $lineObject->getStrokeColor();
$draw->setStrokeColor((string) $color);
$draw->setStrokeOpacity($lineObject->getStrokeAlpha());
$draw->line($lineObject->getPointStart()->getX(), $lineObject->getPointStart()->getY(), $lineObject->getPointEnd()->getX(), $lineObject->getPointEnd()->getY());
$handle->drawImage($draw);
}
示例9: getDraw
public function getDraw()
{
$draw = new \ImagickDraw();
$strokeColor = new \ImagickPixel($this->strokeColor);
$fillColor = new \ImagickPixel($this->fillColor);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
return $draw;
}
示例10: draw
/**
* @param Image $image
*
* @return Image
*/
public function draw($image)
{
$strokeColor = new \ImagickPixel($this->getColor()->getHexString());
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth($this->thickness);
list($x1, $y1) = $this->point1;
list($x2, $y2) = $this->point2;
$draw->line($x1, $y1, $x2, $y2);
$image->getCore()->drawImage($draw);
return $image;
}
示例11: drawText
function drawText(\Imagick $imagick, $shadow = false)
{
$draw = new \ImagickDraw();
if ($shadow == true) {
$draw->setStrokeColor('black');
$draw->setStrokeWidth(8);
$draw->setFillColor('black');
} else {
$draw->setStrokeColor('none');
$draw->setStrokeWidth(1);
$draw->setFillColor('lightblue');
}
$draw->setFontSize(96);
$text = "Imagick\nExample";
$draw->setFont("../fonts/CANDY.TTF");
$draw->setGravity(\Imagick::GRAVITY_SOUTHWEST);
$imagick->annotateimage($draw, 40, 40, 0, $text);
if ($shadow == true) {
$imagick->blurImage(10, 5);
}
return $imagick;
}
示例12: build
public function build()
{
// Prepage image
$this->_canvas = new Imagick();
$this->_canvas->newImage(self::WIDTH, self::HEIGHT, new ImagickPixel("white"));
$color['line'] = new ImagickPixel("rgb(216, 76, 64)");
$color['text'] = new ImagickPixel("rgb(16, 35, 132)");
$color['karma'] = new ImagickPixel("rgb(116, 194, 98)");
$color['force'] = new ImagickPixel("rgb(37, 168, 255)");
$color['bottom_bg'] = new ImagickPixel("rgb(255, 244, 224)");
$color['bg'] = new ImagickPixel("white");
$color['neutral'] = new ImagickPixel("rgb(200, 200, 200)");
$color['habr'] = new ImagickPixel("rgb(83, 121, 139)");
$color['transparent'] = new ImagickPixel("transparent");
// Prepare canvas for drawing main graph
$draw = new ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setStrokeWidth(2);
// Draw bottom bg
define('TOP_SPACER', 10);
$draw = new ImagickDraw();
$draw->setFillColor($color['bg']);
$draw->setStrokeColor($color['habr']);
$draw->polyline(array(array('x' => 0, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => 0), array('x' => self::WIDTH - 1, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => self::HEIGHT - 1), array('x' => 0, 'y' => 0)));
$this->_canvas->drawImage($draw);
$draw->destroy();
// Draw texts
$draw = new ImagickDraw();
$draw->setTextAlignment(Imagick::ALIGN_CENTER);
$draw->setTextAntialias(true);
$draw->setFont(realpath('stuff/consola.ttf'));
$draw->setFontSize(10);
$draw->setFillColor($color['neutral']);
$draw->annotation(self::WIDTH / 2, 26, "рейтинг: " . $this->_rate);
$this->_canvas->drawImage($draw);
$draw->destroy();
$draw = new ImagickDraw();
$draw->setTextAlignment(Imagick::ALIGN_CENTER);
$draw->setTextAntialias(true);
$draw->setTextUnderColor($color['karma']);
$draw->setFillColor($color['bg']);
$draw->setFontSize(12);
$draw->setFont(realpath('stuff/consolab.ttf'));
$draw->annotation(self::WIDTH / 4 + 1, 12, sprintf('%01.2f', $this->_karma));
$draw->setTextUnderColor($color['force']);
$draw->setFillColor($color['bg']);
$draw->annotation(self::WIDTH / 4 * 3 - 1, 12, sprintf('%01.2f', $this->_habraforce));
$this->_canvas->drawImage($draw);
$draw->destroy();
return true;
}
示例13: border
/**
* Add border
* @param integer $width Border width
* @param string $color Border color
* @return Imagick
*/
public function border($width, $color)
{
$border = new \ImagickDraw();
$border->setFillColor('none');
$border->setStrokeColor(new \ImagickPixel($color));
$border->setStrokeWidth($width);
$widthPart = $width / 2;
$border->line(0, 0 + $widthPart, $this->width, 0 + $widthPart);
$border->line(0, $this->height - $widthPart, $this->width, $this->height - $widthPart);
$border->line(0 + $widthPart, 0, 0 + $widthPart, $this->height);
$border->line($this->width - $widthPart, 0, $this->width - $widthPart, $this->height);
$this->image->drawImage($border);
return $this;
}
示例14: renderImage
function renderImage()
{
//Create a ImagickDraw object to draw into.
$draw = new \ImagickDraw();
$darkColor = new \ImagickPixel('brown');
//http://www.imagemagick.org/Usage/compose/#compose_terms
$draw->setStrokeColor($darkColor);
$draw->setFillColor('white');
$draw->setStrokeWidth(2);
$draw->setFontSize(72);
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($darkColor);
$draw->setStrokeWidth(2);
$draw->setFont("../fonts/CANDY.TTF");
$draw->setFontSize(140);
$draw->setFillColor('none');
$draw->rectangle(0, 0, 1000, 300);
$draw->setFillColor('white');
$draw->annotation(50, 180, "Lorem Ipsum!");
$imagick = new \Imagick(realpath("images/TestImage.jpg"));
// $compositeModes = [
//
// \Imagick::COMPOSITE_NO, \Imagick::COMPOSITE_ADD, \Imagick::COMPOSITE_ATOP, \Imagick::COMPOSITE_BLEND, \Imagick::COMPOSITE_BUMPMAP, \Imagick::COMPOSITE_CLEAR, \Imagick::COMPOSITE_COLORBURN, \Imagick::COMPOSITE_COLORDODGE, \Imagick::COMPOSITE_COLORIZE, \Imagick::COMPOSITE_COPYBLACK, \Imagick::COMPOSITE_COPYBLUE, \Imagick::COMPOSITE_COPY, \Imagick::COMPOSITE_COPYCYAN, \Imagick::COMPOSITE_COPYGREEN, \Imagick::COMPOSITE_COPYMAGENTA, \Imagick::COMPOSITE_COPYOPACITY, \Imagick::COMPOSITE_COPYRED, \Imagick::COMPOSITE_COPYYELLOW, \Imagick::COMPOSITE_DARKEN, \Imagick::COMPOSITE_DSTATOP, \Imagick::COMPOSITE_DST, \Imagick::COMPOSITE_DSTIN, \Imagick::COMPOSITE_DSTOUT, \Imagick::COMPOSITE_DSTOVER, \Imagick::COMPOSITE_DIFFERENCE, \Imagick::COMPOSITE_DISPLACE, \Imagick::COMPOSITE_DISSOLVE, \Imagick::COMPOSITE_EXCLUSION, \Imagick::COMPOSITE_HARDLIGHT, \Imagick::COMPOSITE_HUE, \Imagick::COMPOSITE_IN, \Imagick::COMPOSITE_LIGHTEN, \Imagick::COMPOSITE_LUMINIZE, \Imagick::COMPOSITE_MINUS, \Imagick::COMPOSITE_MODULATE, \Imagick::COMPOSITE_MULTIPLY, \Imagick::COMPOSITE_OUT, \Imagick::COMPOSITE_OVER, \Imagick::COMPOSITE_OVERLAY, \Imagick::COMPOSITE_PLUS, \Imagick::COMPOSITE_REPLACE, \Imagick::COMPOSITE_SATURATE, \Imagick::COMPOSITE_SCREEN, \Imagick::COMPOSITE_SOFTLIGHT, \Imagick::COMPOSITE_SRCATOP, \Imagick::COMPOSITE_SRC, \Imagick::COMPOSITE_SRCIN, \Imagick::COMPOSITE_SRCOUT, \Imagick::COMPOSITE_SRCOVER, \Imagick::COMPOSITE_SUBTRACT, \Imagick::COMPOSITE_THRESHOLD, \Imagick::COMPOSITE_XOR,
//
// ];
$draw->composite(\Imagick::COMPOSITE_MULTIPLY, -500, -200, 2000, 600, $imagick);
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage(1000, 300, "SteelBlue2");
$imagick->setImageFormat("png");
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
//Send the image to the browser
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
示例15: test_shape
function test_shape(&$canvas)
{
$draw = new ImagickDraw();
$draw->setFillColor('transparent');
$draw->setStrokeColor('#F02B88');
$draw->setStrokeWidth(9);
$draw->translate(200, 100);
$draw->rectangle(-50, -50, 50, 50);
$draw->translate(200, 100);
$draw->ellipse(0, 0, 100, 80, 0, 360);
$draw->skewX(-30);
$draw->translate(200, 100);
$draw->circle(0, 0, 50, 50);
$canvas->drawImage($draw);
}