本文整理汇总了PHP中Canvas::drawText方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::drawText方法的具体用法?PHP Canvas::drawText怎么用?PHP Canvas::drawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas::drawText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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;
}