本文整理汇总了PHP中float::getCenter方法的典型用法代码示例。如果您正苦于以下问题:PHP float::getCenter方法的具体用法?PHP float::getCenter怎么用?PHP float::getCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类float
的用法示例。
在下文中一共展示了float::getCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderText
/**
* Render text depending of font type and available font extensions
*
* @param string $id
* @param string $text
* @param string $font
* @param ezcGraphColor $color
* @param ezcGraphCoordinate $position
* @param float $size
* @param float $rotation
* @return void
*/
protected function renderText($text, $font, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null)
{
$this->context->selectFontFace($font, CairoFontSlant::NORMAL, CairoFontWeight::NORMAL);
$this->context->setFontSize($size);
// Store current state of context
$this->context->save();
$this->context->moveTo(0, 0);
if ($rotation !== null) {
// Move to the center
$this->context->translate($rotation->getCenter()->x, $rotation->getCenter()->y);
// Rotate around text center
$this->context->rotate(deg2rad($rotation->getRotation()));
// Center the text
$this->context->translate($position->x - $rotation->getCenter()->x, $position->y - $rotation->getCenter()->y - $size * 0.15);
} else {
$this->context->translate($position->x, $position->y - $size * 0.15);
}
$this->context->newPath();
$this->getStyle($color, true);
$this->context->showText($text);
$this->context->stroke();
// Restore state of context
$this->context->restore();
}
示例2: renderText
/**
* Render text depending of font type and available font extensions
*
* @param string $id
* @param string $text
* @param string $font
* @param ezcGraphColor $color
* @param ezcGraphCoordinate $position
* @param float $size
* @param float $rotation
* @return void
*/
protected function renderText($text, $font, ezcGraphColor $color, ezcGraphCoordinate $position, $size, $rotation = null)
{
cairo_select_font_face($this->context, $font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size($this->context, $size);
// Store current state of context
cairo_save($this->context);
cairo_move_to($this->context, 0, 0);
if ($rotation !== null) {
// Move to the center
cairo_translate($this->context, $rotation->getCenter()->x, $rotation->getCenter()->y);
// Rotate around text center
cairo_rotate($this->context, deg2rad($rotation->getRotation()));
// Center the text
cairo_translate($this->context, $position->x - $rotation->getCenter()->x, $position->y - $rotation->getCenter()->y - $size * 0.15);
} else {
cairo_translate($this->context, $position->x, $position->y - $size * 0.15);
}
cairo_new_path($this->context);
$this->getStyle($color, true);
cairo_show_text($this->context, $text);
cairo_stroke($this->context);
// Restore state of context
cairo_restore($this->context);
}