本文整理汇总了PHP中Canvas::getHeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Canvas::getHeight方法的具体用法?PHP Canvas::getHeight怎么用?PHP Canvas::getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas::getHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Display
}
$display = new Display($canvas);
if (!$display) {
die("Error while attaching canvas to display\n");
}
$pig->setColorANSI(AnsiColor::LIGHTMAGENTA, AnsiColor::TRANSPARENT);
$pig->importString($pig_str, "text");
$display->setDisplayTime(20000);
$x = $y = 0;
$ix = $iy = 1;
while (!$display->getEvent(EventType::KEY_PRESS)) {
// In case of resize ...
if ($x + $pig->getWidth() - 1 >= $canvas->getWidth() || $x < 0) {
$x = 0;
}
if ($y + $pig->getHeight() - 1 >= $canvas->getHeight() || $y < 0) {
$y = 0;
}
$canvas->Clear();
// Draw
$canvas->Blit($x, $y, $pig, NULL);
$canvas->setColorANSI(AnsiColor::LIGHTBLUE, AnsiColor::BLACK);
$canvas->putStr($canvas->getWidth() / 2 - 10, $canvas->getHeight() / 2, "Powered by libcaca " . Libcaca::getVersion());
$display->refresh();
// Move cursor
$x += $ix;
$y += $iy;
if ($x + $pig->getWidth() >= $canvas->getWidth() || $x < 0) {
$ix = -$ix;
}
if ($y + $pig->getHeight() >= $canvas->getHeight() || $y < 0) {
示例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;
}