本文整理汇总了PHP中Canvas类的典型用法代码示例。如果您正苦于以下问题:PHP Canvas类的具体用法?PHP Canvas怎么用?PHP Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Canvas类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render
function render(SceneState $ss, ActorState $as, Canvas $c)
{
$font = new TrueTypeFont($this->font, $this->size);
$p = $c->getPainter();
$p->drawFilledRect(0, 0, $c->width, $c->height, rgb($this->background), rgb($this->background));
$c->drawText($font, rgb($this->color), 0, 0, $this->text);
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:text.php
示例2: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
// If not we need to do some enumeration
$total = imagecolorstotal($himage);
if ($total > 0) {
// This works for indexed images but not for truecolor
for ($i = 0; $i < $total; $i++) {
$index = imagecolorsforindex($himage, $i);
$rgb = rgb($index['red'], $index['green'], $index['blue']);
$hsv = hsv($rgb);
$hsv->hue = $this->hue;
$rgb = rgb($hsv);
$red = $rgb->red;
$green = $rgb->green;
$blue = $rgb->blue;
imagecolorset($himage, $i, $red, $green, $blue);
}
} else {
// For truecolor we need to enum it all
for ($x = 0; $x < imagesx($himage); $x++) {
for ($y = 0; $y < imagesy($himage); $y++) {
$index = imagecolorat($himage, $x, $y);
$rgb = rgb($index['red'], $index['green'], $index['blue'], $index['alpha']);
$hsv = hsv($rgb);
$hsv->hue = $this->hue;
$rgb = rgb($hsv);
$red = $rgb->red;
$green = $rgb->green;
$blue = $rgb->blue;
imagesetpixel($himage, $x, $y, $red << 16 | $green < 8 | $blue);
}
}
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:35,代码来源:hue.php
示例3: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
if (function_exists('imagefilter')) {
// If gd is bundled this will work
imagefilter($himage, IMG_FILTER_GRAYSCALE);
} else {
// If not we need to do some enumeration
$total = imagecolorstotal($himage);
if ($total > 0) {
// This works for indexed images but not for truecolor
for ($i = 0; $i < $total; $i++) {
$index = imagecolorsforindex($himage, $i);
$avg = ($index["red"] + $index["green"] + $index["blue"]) / 3;
$red = $avg;
$green = $avg;
$blue = $avg;
imagecolorset($himage, $i, $red, $green, $blue);
}
} else {
// For truecolor we need to enum it all
for ($x = 0; $x < imagesx($himage); $x++) {
for ($y = 0; $y < imagesy($himage); $y++) {
$index = imagecolorat($himage, $x, $y);
$avg = (($index & 0xff) + ($index >> 8 & 0xff) + ($index >> 16 & 0xff)) / 3;
imagesetpixel($himage, $x, $y, $avg | $avg << 8 | $avg << 16);
}
}
}
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:grayscale.php
示例4: draw
function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
{
$image = new Canvas($width, $height);
$p = $image->getPainter();
if (!$x) {
$x = 0;
}
if (!$y) {
$y = 0;
}
if (!$width) {
$width = $dest->width;
}
if (!$height) {
$height = $dest->height;
}
if ($width && $height) {
$grad = $height;
// Top down
$this->colors['step'] = array((double) ($this->colors['delta'][0] / $grad), (double) ($this->colors['delta'][1] / $grad), (double) ($this->colors['delta'][2] / $grad));
$w = $width;
for ($n = 0; $n < $grad; $n++) {
$c = new RgbColor(floor($this->colors['first'][0] + $this->colors['step'][0] * $n), floor($this->colors['first'][1] + $this->colors['step'][1] * $n), floor($this->colors['first'][2] + $this->colors['step'][2] * $n));
// Console::debug("Row %d: rgb(%d,%d,%d)", $n, $c->r, $c->g, $c->b);
$p->drawLine(0, $n, $w, $n, $c);
}
imagecopy($dest->getImage(), $image->getImage(), $x, $y, 0, 0, $width, $height);
} else {
throw new BadArgumentException();
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:gradient.php
示例5: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
$m = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
$div = 16;
$offs = 0;
ImageUtils::imageconvolution($himage, $m, $div, $offs);
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:blur.php
示例6: testInsertX
/**
* @dataProvider getInsertXData
*/
public function testInsertX($x, $w, array $expectedData)
{
$from = [0 => [0 => 'A', 1 => 'B', 2 => 'C'], 1 => [0 => 'D', 1 => 'E', 2 => 'F']];
$from = new Canvas(null, $from);
$to = [0 => [0 => 'X', 1 => 'Y', 2 => 'Z']];
$to = new Canvas(null, $to);
$from->insert($to, 0, $x, 0, $w);
$this->assertEquals($expectedData, $from->getArrayCopy());
}
开发者ID:mathielen,项目名称:report-write-engine,代码行数:12,代码来源:CanvasTest.php
示例7: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
if (function_exists('imagefilter') && defined('IMG_FILTER_COLORIZE')) {
// If gd is bundled this will work
imagefilter($himage, IMG_FILTER_COLORIZE, $this->r, $this->g, $this->b);
} else {
throw new FunctionNotSupportedException("Colorize not supported by this version of GD");
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:10,代码来源:colorize.php
示例8: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
if ($this->usegdfilter) {
if (!imagefilter($himage, IMG_FILTER_PIXELATE, $this->pixelsize, $this->advanced)) {
throw new GraphicsException("Failed to apply filter");
}
} else {
// TODO: Implement our own pixelation filter
}
$canvas->setImage($himage);
return null;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:13,代码来源:pixelize.php
示例9: getMapCanvas
public function getMapCanvas($width, $height)
{
$url = $this->getApiQueryUrl(["w" => $width, "h" => $height]);
$map = file_get_contents($url);
$c = Canvas::createFromString($map);
return $c;
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:7,代码来源:map.php
示例10: test__clone
/**
* @covers Image\Canvas::__clone
*/
public function test__clone()
{
$this->object->createImage(200, 200);
$clone = clone $this->object;
$this->assertEquals($this->object->getImageWidth(), $clone->getImageWidth());
$this->assertEquals($this->object->getImageHeight(), $clone->getImageHeight());
}
开发者ID:npetrovski,项目名称:php5-image,代码行数:10,代码来源:CanvasTest.php
示例11: generateThumb
private static function generateThumb($path, $name, $width, $heigth)
{
$save = self::$path . DIRECTORY_SEPARATOR . $name;
$thumb = \Canvas::Instance();
$thumb->carrega($path);
$thumb->redimensiona($width, $heigth, 'crop');
$thumb->grava($save);
}
开发者ID:fernandopetry,项目名称:pwork,代码行数:8,代码来源:Thumbnail.php
示例12: draw
function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
{
$c = new Canvas($width, $height, rgb($this->props['background']));
$p = $c->getPainter();
$p->drawRect(0, 0, $width - 1, $height - 1, rgb($this->props['bordercolor']));
$labels = $this->dataset->getLabels();
$labelcount = count($labels);
// $ls = floor($height / $labelcount) - 4;
$ls = 16;
for ($i = 0; $i < $labelcount; $i++) {
$x1 = 3;
$y1 = 3 + ($ls + 2) * $i;
$x2 = $x1 + $ls;
$y2 = $y1 + $ls;
$p->drawFilledRect($x1, $y1, $x2, $y2, rgb(80, 80, 80), rgb(rand(0, 200), rand(0, 200), rand(0, 200)));
}
imagecopy($dest->getImage(), $c->getImage(), $x, $y, 0, 0, $width, $height);
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:18,代码来源:legend.php
示例13: 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
示例14: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
$iw = imagesx($himage);
$ih = imagesy($himage);
switch ($this->placement) {
case WatermarkImageFilter::POS_RELATIVE:
$dx = $this->x >= 0 ? $this->x : $iw - $this->width + $this->x + 1;
$dy = $this->y >= 0 ? $this->y : $ih - $this->height + $this->y + 1;
break;
case WatermarkImageFilter::POS_ABSOLUTE:
$dx = $this->x;
$dy = $this->y;
break;
case WatermarkImageFilter::POS_CENTERED:
$dx = $iw / 2 + $this->x;
$dy = $ih / 2 + $this->y;
break;
}
imagecopymerge_alpha($himage, $this->hwatermark, $dx, $dy, 0, 0, $this->width, $this->height, 0);
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:21,代码来源:watermark.php
示例15: applyFilter
function applyFilter(Canvas $canvas)
{
$himage = $canvas->getImage();
$rheight = $this->_os->get('reflectionheight', 25);
$iheight = imagesy($himage);
$iwidth = imagesx($himage);
if ($this->_os->get('resizecanvas', false)) {
// create new canvas of iheight+rheight, set offset to
// iheight
$offs = $iheight;
$hreflect = imagecreatetruecolor($iwidth, $iheight + $rheight);
} else {
// create new canvas of iheight, set offset to iheight to
// iheight-rheight
$offs = $iheight - $rheight;
$hreflect = imagecreatetruecolor($iwidth, $iheight);
}
if ($this->_os->get('background', null)) {
// Fill with background if specified, note that this disables
// the alpha saving
imagefilledrectangle($hreflect, 0, 0, imagesx($hreflect), imagesy($hreflect), new Color($this->_os->get('background')));
} else {
// Disable alphablending and enable saving of the alpha channel
imagealphablending($hreflect, false);
imagesavealpha($hreflect, true);
}
imagecopy($hreflect, $himage, 0, 0, 0, 0, $iwidth, $iheight);
$as = 80 / $rheight;
$sc = $this->_os->get('scale', 2);
for ($y = 1; $y <= $rheight; $y++) {
for ($x = 0; $x < $iwidth; $x++) {
$rgba = imagecolorat($himage, $x, $offs - $y * $sc);
$alpha = max($rgba >> 24 & 0x7f, 47 + $y * $as);
$rgba = imagecolorallocatealpha($hreflect, $rgba >> 16 & 0xff, $rgba >> 8 & 0xff, $rgba & 0xff, $alpha);
imagesetpixel($hreflect, $x, $offs + $y - 1, $rgba);
}
}
return $hreflect;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:39,代码来源:reflection.php
示例16: draw
function draw(Canvas $dest, $x = null, $y = null, $width = null, $height = null)
{
$hi = $dest->getImage();
$str = '*' . $this->_text . '*';
if ($x && $y && $width && $height) {
// Each character is 12 units wide, so let's figure out how wide
// we should make the output. We add 2 for the padding.
$outwidth = strlen($str) * 14;
$unitwidth = (int) ($width / $outwidth);
$rx = 0;
for ($i = 0; $i < strlen($str); $i++) {
$charbin = $this->getCharacter($str[$i]);
for ($j = 0; $j < 9; $j++) {
$bw = $charbin[$j] == '1' ? 1 : 0;
imagefilledrectangle($hi, $x + $rx * $unitwidth, $y, $x + ($rx + $bw + 1) * $unitwidth, $y + $height, $j % 2 ? 0xffffff : 0x0);
$rx = $rx + 2 + $bw;
}
$rx = $rx + 2;
}
} else {
new BadArgumentException();
}
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:23,代码来源:code39.php
示例17: execute
/**
* Executa o upload do arquivo
* @return boolean
*/
public function execute()
{
$this->width = \Local\Config::$cms_image_width;
$this->height = \Local\Config::$cms_image_heigth;
if (\Local\Config::$cms_image_size_reverse_direction) {
if ($this->info[0] < $this->info[1]) {
$this->width = \Local\Config::$cms_image_heigth;
$this->height = \Local\Config::$cms_image_width;
}
}
$upload = \Canvas::Instance(parent::getTmpName());
$upload->redimensiona($this->width, $this->height, \Local\Config::$cms_image_type);
return $upload->grava($this->detination);
}
开发者ID:fernandopetry,项目名称:pwork,代码行数:18,代码来源:Image.php
示例18: deletePortletAction
public function deletePortletAction()
{
$id = $this->request->getPost("id");
$canvas = Canvas::findFirstByid($id);
$widgets = $canvas->Widget;
foreach ($widgets as $widget) {
$widget->delete();
}
if (!$canvas->delete()) {
foreach ($canvas->getMessages() as $message) {
$this->flash->error($message);
}
} else {
$this->flash->success("Portlet was deleted successfully");
}
return $this->dispatcher->forward(array("controller" => "dashboard", "action" => "edit", "params" => array('id' => $canvas->dashboard_id)));
}
开发者ID:enricowillemse,项目名称:prime_admin,代码行数:17,代码来源:PortletController.php
示例19: __construct
function __construct()
{
parent::__construct();
$this->startTime = gettimeofday(true);
$message = " --- POWERED BY LIBCACA --- OLDSCHOOL TEXT EFFECTS ARE 100% PURE WIN";
$this->scroll = new Canvas(strlen($message), 1);
$this->scroll->setColorAnsi(AnsiColor::WHITE, AnsiColor::TRANSPARENT);
$this->scroll->putStr(0, 0, $message);
$fontList = Font::getList();
$f = new Font($fontList[1]);
$w = $f->getWidth() * strlen($message);
$h = $f->getHeight();
$this->image = imagecreatetruecolor($w, $h);
imagealphablending($this->image, false);
imagesavealpha($this->image, true);
$this->d = new Dither($this->image);
$f->Render($this->scroll, $this->image);
}
开发者ID:dns,项目名称:libcaca,代码行数:18,代码来源:test.php
示例20: ExtraFields
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array($contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('product');
$search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_');
if (empty($action)) {
$action = 'list';
}
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$canvas = GETPOST("canvas");
$objcanvas = null;
if (!empty($canvas)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php';
$objcanvas = new Canvas($db, $action);
$objcanvas->getCanvas('product', 'list', $canvas);
}
// Security check
if ($type == '0') {
$result = restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas);
} else {
if ($type == '1') {
$result = restrictedArea($user, 'service', '', '', '', '', '', $objcanvas);
} else {
$result = restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas);
}
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array('p.ref' => "Ref", 'pfp.ref_fourn' => "RefSupplier", 'p.label' => "ProductLabel", 'p.description' => "Description", "p.note" => "Note");
// multilang
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:list.php
注:本文中的Canvas类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论