本文整理汇总了PHP中Canvas::draw方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::draw方法的具体用法?PHP Canvas::draw怎么用?PHP Canvas::draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas::draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyImageFilter
public function applyImageFilter(Canvas $canvas, Rect $rect = null)
{
if ($rect) {
$image = $canvas->getImageRect($rect);
} else {
$image = $canvas;
}
$im = $image->toImagick();
$im->adaptiveSharpenImage($this->radius, $this->sigma);
$image->fromImagick($im);
if ($rect) {
// Draw dest onto canvas
$c = new Canvas();
$c->fromImagick($image);
$c->draw($rect);
} else {
$canvas = $image;
}
return $canvas;
}
示例2: GdEngine
<?php
use Phim\Engine\GdEngine;
$phim = new GdEngine();
//Create basic image and draw a circle on it and save it to a PNG file
//Using: Implicit layer management, Engine shortcuts
$canvas = $phim->create($phim->size(200, 200), $phim->color('#000'));
$canvas->draw($phim->circle($phim->point(100, 100), 100, $phim->fillBrush('#f00')));
//Or in OO style
$canvas = new Canvas(new Size(200, 200), Color::fromString('#000'));
$canvas->draw(new Circle(new Point(100, 100), 100, new FillBrush('#f00')));
//THESE METHODS BELOW ARE THE ONLY PARTS WHERE STUFF ACTUALLY GETS HANDLED THROUGH GD AND IMAGICK
//Everything else is virtual!
//Format detection based on extension (by default)
$engine->save($canvas, $path);
//Explicit conversion in two ways
$engine->save($canvas, $path, 'png');
$engine->save($canvas, $path, FileFormat::PNG);
//Save with compression options etc.
$engine->save($canvas, $path, 'png', new PngSaveOptions(['compression_level' => 9]));
//Get raw output
$output = $engine->render($canvas);
//Pass to client directly
$engine->render($canvas, true);
//Layer management
$backgroundLayer = $canvas->getBackgroundLayer();
//Which is also the layer you draw on with implicit layering
$canvas->layer('example')->draw($phim->square($canvas->getCenter(), 100, $phim->strokeBrush('yellow')))->mask($canvas->mask()->draw($phim->circle($canvas->getCenter, 50, $phim->fillBrush('#fff'))));
$canvas->layer('other-example')->draw();
$canvas->layer('example')->draw();
//save/render