本文整理汇总了PHP中ImagickDraw::setStrokeColor方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setStrokeColor方法的具体用法?PHP ImagickDraw::setStrokeColor怎么用?PHP ImagickDraw::setStrokeColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setStrokeColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: histogram
public function histogram()
{
for ($i = 0; $i <= 256; $i++) {
$this->data[$i] = array('r' => 0, 'g' => 0, 'b' => 0, 'y' => 0);
}
$this->iterate('hist_prepare');
$maxPixelCount = 0;
foreach ($this->data as $k => $v) {
$maxPixelCount = max($maxPixelCount, $v['r'], $v['g'], $v['b'], $v['y']);
}
$this->img->newImage(512, 512, new ImagickPixel('white'));
$this->img->setImageFormat('png');
$draw = new ImagickDraw();
for ($i = 0; $i < 257; $i++) {
$draw->setStrokeColor('#ff0000');
$draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['r'] / $maxPixelCount * 512);
$draw->setStrokeColor('#00ff00');
$draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['g'] / $maxPixelCount * 512);
$draw->setStrokeColor('#0000ff');
$draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['b'] / $maxPixelCount * 512);
$draw->setStrokeColor('#aaaaaa');
$draw->line($i * 2, 512, $i * 2, 512 - $this->data[$i]['y'] / $maxPixelCount * 512);
}
$this->img->drawImage($draw);
}
示例2: 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();
}
示例3: 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);
}
示例4: 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);
}
示例5: draw
/**
* @param ImageInterface $image
* @return Image
*/
public function draw($image)
{
// Localize vars
$width = $image->getWidth();
$height = $image->getHeight();
$imagick = $image->getCore();
$draw = new \ImagickDraw();
$strokeColor = new \ImagickPixel($this->getColor()->getHexString());
$fillColor = new \ImagickPixel('rgba(0,0,0,0)');
$draw->setStrokeOpacity(1);
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
list($x1, $y1) = $this->point1;
list($x2, $y2) = $this->control;
list($x3, $y3) = $this->point2;
$draw->pathStart();
$draw->pathMoveToAbsolute($x1, $y1);
$draw->pathCurveToQuadraticBezierAbsolute($x2, $y2, $x3, $y3);
$draw->pathFinish();
// Render the draw commands in the ImagickDraw object
$imagick->drawImage($draw);
$type = $image->getType();
$file = $image->getImageFile();
return new Image($imagick, $file, $width, $height, $type);
// Create new image with updated core
}
示例6: 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);
}
示例7: ImagickDraw
function __construct()
{
$draw = new ImagickDraw();
$draw->setFillColor('#B42AAF');
$draw->setStrokeColor('black');
$draw->setStrokeWidth(1);
$this->draw = $draw;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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;
}
示例12: 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;
}
示例13: render
function render()
{
$text = "Lorem ipsum";
$im = new \Imagick();
$draw = new \ImagickDraw();
$draw->setStrokeColor("none");
$draw->setFont("../fonts/Arial.ttf");
$draw->setFontSize(96);
$draw->setTextAlignment(\Imagick::ALIGN_LEFT);
$metrics = $im->queryFontMetrics($draw, $text);
return print_table($metrics);
}
示例14: 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;
}
示例15: 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;
}