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


PHP Canvas::getPainter方法代码示例

本文整理汇总了PHP中Canvas::getPainter方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::getPainter方法的具体用法?PHP Canvas::getPainter怎么用?PHP Canvas::getPainter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canvas的用法示例。


在下文中一共展示了Canvas::getPainter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: render3D

 /**
  * @brief Render the chart in 3D
  * 
  * @return Canvas 
  */
 private function render3D()
 {
     $c = new Canvas($this->width, $this->height, rgb($this->getProperty('background', '#FFFFFF')));
     $radiusx = 180;
     $radiusy = 90;
     $cx = $c->getWidth() / 2;
     $cy = $c->getHeight() / 2;
     $explode = $this->getProperty('explode', 0);
     $palette = $this->getProperty('palette');
     list($label, $vals) = $this->dataset->getSeries(0);
     $labels = $this->dataset->getLabels();
     $sum = $vals->getSum();
     $ci = 0;
     $sa = 0;
     for ($n = 0; $n < $vals->getCount(); $n++) {
         list($val, $key) = $vals->getValue($n);
         $a = 360 / $sum * $val;
         // Get angle
         $ea = $sa + $a;
         $ch = rgb($palette[$ci]);
         $cs = hsv($ch);
         $cs->value = $cs->value - 30;
         if (arr::hasKey($labels, $n)) {
             $l = $labels[$n];
         } else {
             $l = $n;
         }
         $data[] = array('key' => $key, 'label' => $l, 'c1' => $ch, 'c2' => $cs, 'sa' => $sa, 'ea' => $ea);
         $sa = $ea;
         $ci++;
     }
     $offs = array();
     foreach ($data as $id => $slice) {
         $avg = ($slice['sa'] + $slice['ea']) / 2;
         $data[$id]['ox'] = cos(($avg - 90) % 360 * PI / 180) * $explode;
         $data[$id]['oy'] = sin(($avg - 90) % 360 * PI / 180) * $explode;
         $data[$id]['dx'] = cos(($avg - 180) % 360 * PI / 180);
         $data[$id]['dy'] = sin(($avg - 180) % 360 * PI / 180);
     }
     $f = new BitmapFont(3);
     $f->setTextEffect(BitmapFont::EFFECT_OUTLINE, rgb(255, 255, 255));
     $p = $c->getPainter();
     for ($yp = 20; $yp >= 0; $yp--) {
         foreach ($data as $slice) {
             $ox = $slice['ox'];
             $oy = $slice['oy'];
             $p->drawFilledArc($cx + $ox, $cy + $oy + $yp, $radiusx * 2, $radiusy * 2, $slice['sa'], $slice['ea'], $yp == 0 ? $slice['c1'] : $slice['c2']);
         }
     }
     for ($yp = 20; $yp >= 0; $yp--) {
         foreach ($data as $slice) {
             // TODO: Labels
             $m = $f->measure($slice['label']);
             $dx = $slice['dx'];
             $dy = $slice['dy'];
             $c->drawText($f, rgb(0, 0, 0), $cx + $dx * $radiusx / 1.5 - $m['width'] / 2, $cx + $dy * $radiusy / 1.5 - $m['height'] / 2, $slice['label']);
         }
     }
     $this->renderObjects($c);
     // Return the canvas
     return $c;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:67,代码来源:piechart.php


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