本文整理汇总了PHP中ImagickDraw::setFillColor方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setFillColor方法的具体用法?PHP ImagickDraw::setFillColor怎么用?PHP ImagickDraw::setFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setFillColor方法的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: makeImageOfCertification
public function makeImageOfCertification()
{
date_default_timezone_set('UTC');
$timeStamp = date('jS F Y');
$text = "CERTIFIED COPY" . "\n" . $this->serial . "\n" . $timeStamp;
$image = new \Imagick();
$draw = new \ImagickDraw();
$color = new \ImagickPixel('#000000');
$background = new \ImagickPixel("rgb(85, 196, 241)");
$draw->setFont($this->container->getParameter('assetic.write_to') . $this->container->get('templating.helper.assets')->getUrl('fonts/futura.ttf'));
$draw->setFontSize(24);
$draw->setFillColor($color);
$draw->setTextAntialias(true);
$draw->setStrokeAntialias(true);
//Align text to the center of the background
$draw->setTextAlignment(\Imagick::ALIGN_CENTER);
//Get information of annotation image
$metrics = $image->queryFontMetrics($draw, $text);
//Calc the distance(pixels) to move the sentences
$move = $metrics['textWidth'] / 2;
$draw->annotation($move, $metrics['ascender'], $text);
//Create an image of certification
$image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
$image->setImageFormat('png');
$image->drawImage($draw);
//Save an image temporary
$image->writeImage("cert_" . $this->serial . "_.png");
}
示例3: __construct
/**
* Creates a new Label component.
*
* @param OsuSignature $signature The base signature
* @param int $x The X position of this label
* @param int $y The Y position of this label
* @param string $text The text of this label
* @param string $font The font to use for this label; can be a string or the constants defined in {@link ComponentLabel}
* @param string $colour The colour of the text of the label
* @param int $fontSize The size of the font of the label
* @param int $textAlignment The text alignment
* @param int $width Width of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system. -2 makes the component sizeless
* @param int $height Height of the label, set to -1 to use the text size, anything bigger can be used to spoof the component system
*/
public function __construct(OsuSignature $signature, $x = 0, $y = 0, $text, $font = self::FONT_REGULAR, $colour = '#555555', $fontSize = 14, $textAlignment = Imagick::ALIGN_UNDEFINED, $width = -1, $height = -1)
{
parent::__construct($signature, $x, $y);
$this->text = $text;
$this->font = $font;
$this->colour = $colour;
$this->fontSize = $fontSize;
$this->textAlignment = $textAlignment;
$this->width = $width;
$this->height = $height;
$this->drawSettings = new ImagickDraw();
$this->drawSettings->setFont(self::FONT_DIRECTORY . $font);
$this->drawSettings->setFontSize($fontSize);
$this->drawSettings->setTextAlignment($textAlignment);
$this->drawSettings->setFillColor($colour);
$this->usesSpace = $width != -2;
if ($width <= -1 || $height <= -1) {
$tempImg = new Imagick();
$metrics = $tempImg->queryFontMetrics($this->drawSettings, $this->text);
$this->width = $width <= -1 ? $metrics['textWidth'] : $width;
// yeah i have to do some bullshit
$this->actualWidth = $metrics['textWidth'];
$this->height = $metrics['boundingBox']['y2'] - $this->y;
}
}
示例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: generateImage
private function generateImage()
{
$this->generatedImage = new \Imagick();
$rgbBackgroundColor = $this->getBackgroundColor();
if (null === $rgbBackgroundColor) {
$background = 'none';
} else {
$background = new \ImagickPixel("rgb({$rgbBackgroundColor['0']},{$rgbBackgroundColor['1']},{$rgbBackgroundColor['2']})");
}
$this->generatedImage->newImage($this->pixelRatio * 5, $this->pixelRatio * 5, $background, 'png');
// prepare color
$rgbColor = $this->getColor();
$color = new \ImagickPixel("rgb({$rgbColor['0']},{$rgbColor['1']},{$rgbColor['2']})");
$draw = new \ImagickDraw();
$draw->setFillColor($color);
// draw the content
foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
foreach ($lineValue as $colKey => $colValue) {
if (true === $colValue) {
$draw->rectangle($colKey * $this->pixelRatio, $lineKey * $this->pixelRatio, ($colKey + 1) * $this->pixelRatio, ($lineKey + 1) * $this->pixelRatio);
}
}
}
$this->generatedImage->drawImage($draw);
return $this;
}
示例6: 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
}
示例7: Imagick
function page_testfonts()
{
//load background
$im = new Imagick();
$im->newimage(800, 10000, 'lightgray');
$y = 10;
$i = 1;
foreach ($im->queryFonts() as $font) {
$insert_image = new Imagick();
$insert_image->newImage(600, 30, 'whitesmoke');
$insert_image->setImageFormat("png");
$draw = new ImagickDraw();
$draw->setFont($font);
$draw->setFontSize(25);
$draw->setFillColor(new ImagickPixel('black'));
$draw->setgravity(imagick::GRAVITY_NORTH);
$insert_image->annotateImage($draw, 0, 0, 0, $i . '.' . $font);
$im->compositeImage($insert_image, $insert_image->getImageCompose(), 100, $y);
$y += 30;
$i++;
}
$im->setImageFormat('jpg');
header('Content-Type: image/jpg');
echo $im;
}
示例8: drawBackground
/**
* Draws the background colour for the signature.
* Note that this has no relation to {@link Card}s.
*
* @param $hexColour string Hexadecimal colour value
*/
protected function drawBackground($hexColour)
{
$background = new ImagickDraw();
$background->setFillColor($hexColour);
$background->rectangle(0, 0, $this->canvas->getImageWidth(), $this->canvas->getImageHeight());
$this->canvas->drawImage($background);
}
示例9: writeText
function writeText($text)
{
if ($this->printer == null) {
throw new LogicException("Not attached to a printer.");
}
if ($text == null) {
return;
}
$text = trim($text, "\n");
/* Create Imagick objects */
$image = new \Imagick();
$draw = new \ImagickDraw();
$color = new \ImagickPixel('#000000');
$background = new \ImagickPixel('white');
/* Create annotation */
//$draw -> setFont('Arial');// (not necessary?)
$draw->setFontSize(24);
// Size 21 looks good for FONT B
$draw->setFillColor($color);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
$metrics = $image->queryFontMetrics($draw, $text);
$draw->annotation(0, $metrics['ascender'], $text);
/* Create image & draw annotation on it */
$image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
$image->setImageFormat('png');
$image->drawImage($draw);
//$image -> writeImage("test.png");
/* Save image */
$escposImage = new EscposImage();
$escposImage->readImageFromImagick($image);
$size = Printer::IMG_DEFAULT;
$this->printer->bitImage($escposImage, $size);
}
示例10: 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);
}
示例11: image
private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, $format = "png", $quality = 85, $filename = FALSE, $save = TRUE, $print = false)
{
$imgH = count($frame);
$imgW = strlen($frame[0]);
$col[0] = new \ImagickPixel("white");
$col[1] = new \ImagickPixel("black");
$image = new \Imagick();
$image->newImage($imgW, $imgH, $col[0]);
$image->setCompressionQuality($quality);
$image->setImageFormat($format);
$draw = new \ImagickDraw();
$draw->setFillColor($col[1]);
for ($y = 0; $y < $imgH; $y++) {
for ($x = 0; $x < $imgW; $x++) {
if ($frame[$y][$x] == '1') {
$draw->point($x, $y);
}
}
}
$image->drawImage($draw);
$image->borderImage($col[0], $outerFrame, $outerFrame);
$image->scaleImage(($imgW + 2 * $outerFrame) * $pixelPerPoint, 0);
if ($save) {
if ($filename === false) {
throw new Exception("QR Code filename can't be empty");
}
$image->writeImages($filename, true);
}
if ($print) {
Header("Content-type: image/" . $format);
echo $image;
}
}
示例12: fill
/**
* Flood the image with a color fill.
*
* @param int $r
* @param int $g
* @param int $b
* @return Imagick
*/
public function fill($r, $g, $b)
{
$draw = new \ImagickDraw();
$draw->setFillColor($this->image->getColor([(int) $r, (int) $g, (int) $b]));
$draw->rectangle(0, 0, $this->image->getWidth(), $this->image->getHeight());
$this->image->resource()->drawImage($draw);
return $this;
}
示例13: 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)");
// Prepare canvas for drawing main graph
$draw = new ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setStrokeWidth(2);
// Prepare values for drawing main graph
define('PADDING', 10);
// 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->setFillColor($color['karma']);
$draw->polyline(array(array('x' => 1, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => 1), array('x' => self::WIDTH / 2, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => self::HEIGHT - 2), array('x' => 1, 'y' => 1)));
$draw->setFillColor($color['bg']);
$draw->setFontSize(11);
$draw->setFont(realpath('stuff/consolab.ttf'));
$draw->annotation(self::WIDTH / 4, 11, sprintf('%01.2f', $this->_karma));
$draw->setFillColor($color['force']);
$draw->polyline(array(array('x' => self::WIDTH / 2 + 1, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => 1), array('x' => self::WIDTH - 2, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => self::HEIGHT - 2), array('x' => self::WIDTH / 2 + 1, 'y' => 1)));
$draw->setFillColor($color['bg']);
$draw->annotation(self::WIDTH / 4 * 3, 11, sprintf('%01.2f', $this->_habraforce));
$this->_canvas->drawImage($draw);
$draw->destroy();
return true;
}
示例14: printText
public function printText($canvas, $size, $angle, $x, $y, $color, $fontfile, $text, $opacity = 100)
{
$draw = new ImagickDraw();
$draw->setFillColor(self::rgb($color));
$draw->setFontSize($size * $this->fontSizeScale);
$draw->setFont($fontfile);
$draw->setFillOpacity($opacity / 100);
$canvas->annotateImage($draw, $x, $y, $angle, $text);
}
示例15: 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;
}