本文整理汇总了PHP中ImagePSText函数的典型用法代码示例。如果您正苦于以下问题:PHP ImagePSText函数的具体用法?PHP ImagePSText怎么用?PHP ImagePSText使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImagePSText函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addText
/**
* addText
*
* @param array options Array contains options
* array(
* 'text' The string to draw
* 'x' Horizontal position
* 'y' Vertical Position
* 'Color' Font color
* 'font' Font to be used
* 'size' Size of the fonts in pixel
* 'resize_first' Tell if the image has to be resized
* before drawing the text
* )
*
* @return none
* @see PEAR::isError()
*/
function addText($params)
{
$default_params = array('text' => 'This is Text', 'x' => 10, 'y' => 20, 'color' => array(255, 0, 0), 'font' => 'Arial.ttf', 'size' => '12', 'angle' => 0, 'resize_first' => false);
$params = array_merge($default_params, $params);
extract($params);
if (!is_array($color)) {
if ($color[0] == '#') {
$this->colorhex2colorarray($color);
} else {
include_once 'Image/Transform/Driver/ColorsDefs.php';
$color = isset($colornames[$color]) ? $colornames[$color] : false;
}
}
$c = imagecolorresolve($this->imageHandle, $color[0], $color[1], $color[2]);
if ('ttf' == substr($font, -3)) {
ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
} else {
ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
}
return true;
}
示例2: addText
/**
* addText
*
* @param array $params Array contains options
* array(
* 'text' The string to draw
* 'x' Horizontal position
* 'y' Vertical Position
* 'color' Font color
* 'font' Font to be used
* 'size' Size of the fonts in pixel
* 'resize_first' Tell if the image has to be resized
* before drawing the text
* )
*
* @return bool|PEAR_Error TRUE or a PEAR_Error object on error
*/
function addText($params)
{
$params = array_merge($this->_get_default_text_params(), $params);
extract($params);
$options = array('fontColor' => $color);
$color = $this->_getColor('fontColor', $options, array(0, 0, 0));
$c = imagecolorresolve($this->imageHandle, $color[0], $color[1], $color[2]);
if ('ttf' == substr($font, -3)) {
ImageTTFText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
} else {
ImagePSText($this->imageHandle, $size, $angle, $x, $y, $c, $font, $text);
}
return true;
}
示例3: ImagePSCenter
<?php
function ImagePSCenter($image, $text, $font, $size, $space = 0, $tightness = 0, $angle = 0)
{
// find the size of the image
$xi = ImageSX($image);
$yi = ImageSY($image);
// find the size of the text
list($xl, $yl, $xr, $yr) = ImagePSBBox($text, $font, $size, $space, $tightness, $angle);
// compute centering
$x = intval(($xi - $xr) / 2);
$y = intval(($yi + $yr) / 2);
return array($x, $y);
}
$image = ImageCreate(500, 500);
$text = 'PHP Cookbook Rules!';
$font = ImagePSLoadFont('/path/to/font.pfb');
$size = 20;
$black = 0x0;
$white = 0xffffff;
list($x, $y) = ImagePSCenter($image, $text, $font, $size);
ImagePSText($image, $text, $font, $size, $white, $black, $x, $y);
ImagePSFreeFont($font);
header('Content-type: image/png');
ImagePng($image);
ImageDestroy($image);
示例4: list
<?php
list($x, $y) = pc_ImagePSCenter($image, $text, $font, $size);
ImagePSText($image, $text, $font, $size, $fore, $back, $x, $y);
示例5: ImagePSLoadFont
<?php
$font = ImagePSLoadFont('/path/to/font.pfb');
ImagePSText($image, $text, $font, $size, $text_color, $background_color, $x, $y);
ImagePSFreeFont($font);
示例6: ImagePSText
<?php
// normal image
ImagePSText($image, $text, $font, $size, $black, $white, $x, $y, 0, 0, 0, 4);
// extra space between words
ImagePSText($image, $text, $font, $size, $black, $white, $x, $y + 30, 100, 0, 0, 4);
// extra space between letters
ImagePSText($image, $text, $font, $size, $black, $white, $x, $y + 60, 0, 100, 0, 4);
示例7: ImagePSLoadFont
<?php
$font = ImagePSLoadFont('/path/to/font.pfb');
ImagePSText($image, 'I love PHP Cookbook', $font, $size, $text_color, $background_color, $x, $y);