本文整理汇总了PHP中Image_Canvas::addText方法的典型用法代码示例。如果您正苦于以下问题:PHP Image_Canvas::addText方法的具体用法?PHP Image_Canvas::addText怎么用?PHP Image_Canvas::addText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image_Canvas
的用法示例。
在下文中一共展示了Image_Canvas::addText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addText
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
示例2: addText
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$text = $params['text'];
$color = isset($params['color']) ? $params['color'] : false;
$alignment = isset($params['alignment']) ? $params['alignment'] : false;
$textHeight = $this->textHeight($text);
if (!is_array($alignment)) {
$alignment = array('vertical' => 'top', 'horizontal' => 'left');
}
if (!isset($alignment['vertical'])) {
$alignment['vertical'] = 'top';
}
if (!isset($alignment['horizontal'])) {
$alignment['horizontal'] = 'left';
}
$align = '';
if (isset($this->_font['vertical']) && $this->_font['vertical']) {
// $align .= 'writing-mode: tb-rl;';
if ($alignment['vertical'] == 'bottom') {
$align .= 'text-anchor:end;';
//$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
//$y = $y + ($textHeight / 2);
$align .= 'text-anchor:middle;';
}
} else {
if ($alignment['horizontal'] == 'right') {
$align .= 'text-anchor:end;';
} elseif ($alignment['horizontal'] == 'center') {
$align .= 'text-anchor:middle;';
}
if ($alignment['vertical'] == 'top') {
$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
$y = $y + $textHeight / 2;
}
}
if ($color === false && isset($this->_font['color'])) {
$color = $this->_font['color'];
}
$textColor = $this->_color($color);
$textOpacity = $this->_opacity($color);
$this->_addElement('<g transform="translate(' . round($x) . ', ' . round($y) . ')">' . "\n" . $this->_indent . ' <text ' . 'x="0" ' . 'y="0" ' . (isset($this->_font['angle']) && $this->_font['angle'] > 0 ? 'transform="rotate(' . $this->_font['angle'] . ')" ' : '') . 'style="' . (isset($this->_font['name']) ? 'font-family:' . $this->_font['name'] . ';' : '') . 'font-size:' . $this->_font['size'] . 'px;fill:' . $textColor . ($textOpacity ? ';fill-opacity:' . $textOpacity : '') . ';' . $align . '">' . htmlspecialchars($text) . '</text>' . "\n" . $this->_indent . '</g>', $params);
parent::addText($params);
}
示例3: addText
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$text = $params['text'];
$color = isset($params['color']) ? $params['color'] : false;
$alignment = isset($params['alignment']) ? $params['alignment'] : false;
$this->_setFont();
$textWidth = $this->textWidth($text);
$textHeight = $this->textHeight($text);
if (!is_array($alignment)) {
$alignment = array('vertical' => 'top', 'horizontal' => 'left');
}
if (!isset($alignment['vertical'])) {
$alignment['vertical'] = 'top';
}
if (!isset($alignment['horizontal'])) {
$alignment['horizontal'] = 'left';
}
if ($alignment['horizontal'] == 'right') {
$x = $x - $textWidth;
} elseif ($alignment['horizontal'] == 'center') {
$x = $x - $textWidth / 2;
}
if ($alignment['vertical'] == 'top') {
$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
$y = $y + $textHeight / 2;
}
if ($color === false && isset($this->_font['color'])) {
$color = $this->_font['color'];
}
pdf_show_xy($this->_pdf, $text, $this->_getX($x), $this->_getY($y));
parent::addText($params);
}
示例4: addText
/**
* Writes text
*
* Parameter array:
* 'x' : int X-point of text
* 'y' : int Y-point of text
* 'text' : string The text to add
* 'color' : mixed [optional] The color of the text
*
* @param array $params Parameter array
*
* @todo Vertical alignment
* @return void
*/
function addText($params)
{
$x0 = $this->_getX($params['x']);
$y0 = $this->_getY($params['y']);
$text = str_replace("\r", '', $params['text']);
$color = isset($params['color']) ? $params['color'] : false;
$textHeight = $this->textHeight($text);
$alignment = isset($params['alignment']) ? $params['alignment'] : false;
if (!is_array($alignment)) {
$alignment = array('vertical' => 'top', 'horizontal' => 'left');
}
if (!isset($alignment['vertical'])) {
$alignment['vertical'] = 'top';
}
if (!isset($alignment['horizontal'])) {
$alignment['horizontal'] = 'left';
}
if ($color === false && isset($this->_font['color'])) {
$color = $this->_font['color'];
}
if ($color == 'transparent') {
return;
}
if (strpos($this->_font['file'], '.') === false) {
$this->_font['file'] = IMAGE_CANVAS_SYSTEM_FONT_PATH . $this->_font['file'] . '.fdb';
}
$textColor = $this->_color($color);
$textOpacity = $this->_opacity($color);
$lines = explode("\n", $text);
foreach ($lines as $line) {
$x = $x0;
$y = $y0;
$y0 += $textHeight + 2;
$width = $this->textWidth($line);
$height = $this->textHeight($line);
if ($alignment['horizontal'] == 'right') {
$x -= $width;
} else {
if ($alignment['horizontal'] == 'center') {
$x -= $width / 2;
}
}
$font = new SWFFont($this->_font['file']);
$text = new SWFText();
$text->setFont($font);
$text->moveTo($x, $y + $this->_font['size']);
$text->setColor($textColor[0], $textColor[1], $textColor[2], $textOpacity);
$text->setHeight($this->_font['size']);
$text->addString($line);
$this->_canvas->add($text);
}
parent::addText($params);
}