当前位置: 首页>>代码示例>>PHP>>正文


PHP Canvas::draw方法代码示例

本文整理汇总了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;
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:20,代码来源:adaptivesharpen.php

示例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
开发者ID:talesoft,项目名称:phim,代码行数:31,代码来源:how-to.php


注:本文中的Canvas::draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。