当前位置: 首页>>代码示例>>PHP>>正文


PHP ImagePSText函数代码示例

本文整理汇总了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;
 }
开发者ID:blacksqr,项目名称:portable-nsd,代码行数:39,代码来源:GD.php

示例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;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:31,代码来源:GD.php

示例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);
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:26,代码来源:centered7.php

示例4: list

<?php

list($x, $y) = pc_ImagePSCenter($image, $text, $font, $size);
ImagePSText($image, $text, $font, $size, $fore, $back, $x, $y);
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:4,代码来源:centered4.php

示例5: ImagePSLoadFont

<?php

$font = ImagePSLoadFont('/path/to/font.pfb');
ImagePSText($image, $text, $font, $size, $text_color, $background_color, $x, $y);
ImagePSFreeFont($font);
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:5,代码来源:text6.php

示例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);
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:8,代码来源:text7.php

示例7: ImagePSLoadFont

<?php

$font = ImagePSLoadFont('/path/to/font.pfb');
ImagePSText($image, 'I love PHP Cookbook', $font, $size, $text_color, $background_color, $x, $y);
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:4,代码来源:text3.php


注:本文中的ImagePSText函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。