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


PHP Image::text方法代码示例

本文整理汇总了PHP中Intervention\Image\Image::text方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::text方法的具体用法?PHP Image::text怎么用?PHP Image::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Intervention\Image\Image的用法示例。


在下文中一共展示了Image::text方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: text

 protected function text()
 {
     if ($this->text) {
         $x = $this->fontPadding;
         $y = $this->fontPadding;
         switch ($this->fontAlignHorizontal) {
             case 'center':
                 $x = $this->image->getWidth() / 2;
                 $this->fontAlignHorizontal = 'center';
                 break;
             case 'right':
                 $x = $this->image->getWidth() - 3 - $this->fontPadding;
                 $this->fontAlignHorizontal = 'right';
                 break;
         }
         switch ($this->fontAlignVertical) {
             case 'middle':
                 $y = $this->image->getHeight() / 2 + $this->fontPadding;
                 $this->fontAlignVertical = 'middle';
                 break;
             case 'bottom':
                 $y = $this->image->getHeight() - 4 - $this->fontPadding;
                 break;
         }
         $this->image->text($this->text, $x, $y, function ($font) {
             /* @var $font \Intervention\Image\Imagick\Font */
             $fontType = $_ENV['base_path'] . 'fonts' . DIRECTORY_SEPARATOR . $this->font . ".ttf";
             $font->file($fontType);
             $font->color('#' . $this->fontColor);
             $font->size($this->fontSize);
             $font->valign($this->fontAlignVertical);
             $font->align($this->fontAlignHorizontal);
             if ($this->fontFit == 'max') {
                 $maxWidth = $this->image->getWidth();
                 $fontSize = $this->fontSize;
                 while (true) {
                     $font->size($fontSize);
                     $metrics = $this->getResourceSize($fontType, $this->text, $fontSize, 0);
                     if ($metrics['width'] <= $maxWidth) {
                         break;
                     }
                     $fontSize = (double) $fontSize - 0.1;
                     if ($fontSize <= 0) {
                         break;
                     }
                 }
             }
         });
     }
 }
开发者ID:Monori,项目名称:imgback,代码行数:50,代码来源:ImageHandler.php

示例2: writeContent

 /**
  * @param Image $image
  * @param NodeInfo $node
  */
 protected function writeContent(Image $image, NodeInfo $node)
 {
     $content = $node->content();
     $rect = $node->rectangle();
     foreach ($content->content() as $line) {
         $image->text($line[0], $rect->left + $line[1], $rect->top + $line[2], function (AbstractFont $font) use($line) {
             $font->color($line[4]);
             $font->size($line[3]);
             $font->align($line[5]);
             $font->valign($line[6]);
             $font->file(static::$fontPath);
         });
     }
 }
开发者ID:codeagent,项目名称:treemap,代码行数:18,代码来源:ImagePresenter.php

示例3: text

 /**
  * Write text in current image
  *
  * @param string $text
  * @param integer $pos_x
  * @param integer $pos_y
  * @param integer $angle
  * @param integer $size
  * @param string $color
  * @param string $fontfile
  * @return \Intervention\Image\Image 
  * @static 
  */
 public static function text($text, $pos_x = 0, $pos_y = 0, $size = 16, $color = '000000', $angle = 0, $fontfile = null)
 {
     return \Intervention\Image\Image::text($text, $pos_x, $pos_y, $size, $color, $angle, $fontfile);
 }
开发者ID:jorzhikgit,项目名称:MLM-Nexus,代码行数:17,代码来源:_ide_helper.php

示例4: text

 /**
  * Compatibility method to decide old or new style of text writing
  *
  * @param string $text
  * @param integer $posx
  * @param integer $posy
  * @param mixed $size_or_callback
  * @param string $color
  * @param integer $angle
  * @param string $fontfile
  * @return \Intervention\Image\Image 
  * @static 
  */
 public static function text($text, $posx = 0, $posy = 0, $size_or_callback = null, $color = '000000', $angle = 0, $fontfile = null)
 {
     return \Intervention\Image\Image::text($text, $posx, $posy, $size_or_callback, $color, $angle, $fontfile);
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:17,代码来源:_ide_helper.php

示例5: paymentInformation

 protected function paymentInformation()
 {
     $multiplier = 0;
     if ($this->order->getDueDate()) {
         $this->image->text('&#xe660;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('dueDate') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getDueDate()->format('d/m/Y'), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getAccountNumber()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('accountNumber') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getAccountNumber(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getIBan()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text(Strings::upper($this->translate('iban')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getIBan(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getAccount()->getSwift()) {
         $this->image->text('&#xe645;', 1445, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text(Strings::upper($this->translate('swift')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getAccount()->getSwift(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getPayment()->getVariableSymbol()) {
         $this->image->text('&#xe6a3;', 1455, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('varSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->size(27);
             $font->file($this->template->getFont());
         });
         $this->image->text($this->order->getPayment()->getVariableSymbol(), 1850, 705 + $multiplier * 55, function (Font $font) {
             $font->size(27);
             $font->file($this->template->getFont());
             $font->color($this->template->getFontColor());
         });
         $multiplier++;
     }
     if ($this->order->getPayment()->getConstantSymbol()) {
         $this->image->text('&#xe6a3;', 1455, 710 + $multiplier * 55, function (Font $font) {
             $font->color($this->template->getPrimaryColor());
             $font->file($this->template->getIconFont());
             $font->size(37);
         });
         $this->image->text($this->translate('constSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) {
//.........这里部分代码省略.........
开发者ID:webchemistry,项目名称:invoice,代码行数:101,代码来源:Invoice.php


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