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


PHP I18N::reverseText方法代码示例

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


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

示例1: embedText

 /**
  * Embed a text in an image.
  * Similar to the the media firewall function.
  *
  * @param resource $im Image to watermark
  * @param string $text Text to display
  * @param int $maxsize Maximum size for the font
  * @param string $color Font color
  * @param string $font Font to be used
  * @param string $vpos Description of the vertical position (top, middle, bottom, accross)
  * @param string $hpos Description of the horizontal position (right, left, top2bottom, bottom2top)
  */
 protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos)
 {
     // there are two ways to embed text with PHP
     // (preferred) using GD and FreeType you can embed text using any True Type font
     // (fall back) if that is not available, you can insert basic monospaced text
     $col = $this->hexrgb($color);
     $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']);
     // make adjustments to settings that imagestring and imagestringup can’t handle
     if (!$this->use_ttf) {
         // imagestringup only writes up, can’t use top2bottom
         if ($hpos === 'top2bottom') {
             $hpos = 'bottom2top';
         }
     }
     $text = I18N::reverseText($text);
     $height = imagesy($im);
     $width = imagesx($im);
     $calc_angle = rad2deg(atan($height / $width));
     $hypoth = $height / sin(deg2rad($calc_angle));
     // vertical and horizontal position of the text
     switch ($vpos) {
         default:
         case 'top':
             $taille = $this->textLength($maxsize, $width, $text);
             $pos_y = $height * 0.15 + $taille;
             $pos_x = $width * 0.15;
             $rotation = 0;
             break;
         case 'middle':
             $taille = $this->textLength($maxsize, $width, $text);
             $pos_y = ($height + $taille) / 2;
             $pos_x = $width * 0.15;
             $rotation = 0;
             break;
         case 'bottom':
             $taille = $this->textLength($maxsize, $width, $text);
             $pos_y = $height * 0.85 - $taille;
             $pos_x = $width * 0.15;
             $rotation = 0;
             break;
         case 'across':
             switch ($hpos) {
                 default:
                 case 'left':
                     $taille = $this->textLength($maxsize, $hypoth, $text);
                     $pos_y = $height * 0.85 - $taille;
                     $pos_x = $width * 0.15;
                     $rotation = $calc_angle;
                     break;
                 case 'right':
                     $taille = $this->textLength($maxsize, $hypoth, $text);
                     $pos_y = $height * 0.15 - $taille;
                     $pos_x = $width * 0.85;
                     $rotation = $calc_angle + 180;
                     break;
                 case 'top2bottom':
                     $taille = $this->textLength($maxsize, $height, $text);
                     $pos_y = $height * 0.15 - $taille;
                     $pos_x = $width * 0.9 - $taille;
                     $rotation = -90;
                     break;
                 case 'bottom2top':
                     $taille = $this->textLength($maxsize, $height, $text);
                     $pos_y = $height * 0.85;
                     $pos_x = $width * 0.15;
                     $rotation = 90;
                     break;
             }
             break;
     }
     // apply the text
     if ($this->use_ttf) {
         // if imagettftext throws errors, catch them with a custom error handler
         set_error_handler(array($this, 'imageTtfTextErrorHandler'));
         imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text);
         restore_error_handler();
     }
     // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
     if (!$this->use_ttf) {
         if ($rotation !== 90) {
             imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
         } else {
             imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor);
         }
     }
 }
开发者ID:jon48,项目名称:webtrees-lib,代码行数:98,代码来源:ImageBuilder.php

示例2: generateFanChart

 /**
  * Generate both the HTML and PNG components of the fan chart
  *
  * The HTML and PNG components both require the same co-ordinate calculations,
  * so we generate them using the same code, but we send them in separate
  * HTTP requests.
  *
  * @param string $what "png" or "html"
  *
  * @return string
  */
 public function generateFanChart($what)
 {
     $treeid = $this->sosaAncestors($this->generations);
     $fanw = 640 * $this->fan_width / 100;
     $fandeg = 90 * $this->fan_style;
     $html = '';
     $treesize = count($treeid) + 1;
     // generations count
     $gen = log($treesize) / log(2) - 1;
     $sosa = $treesize - 1;
     // fan size
     if ($fandeg == 0) {
         $fandeg = 360;
     }
     $fandeg = min($fandeg, 360);
     $fandeg = max($fandeg, 90);
     $cx = $fanw / 2 - 1;
     // center x
     $cy = $cx;
     // center y
     $rx = $fanw - 1;
     $rw = $fanw / ($gen + 1);
     $fanh = $fanw;
     // fan height
     if ($fandeg == 180) {
         $fanh = round($fanh * ($gen + 1) / ($gen * 2));
     }
     if ($fandeg == 270) {
         $fanh = round($fanh * 0.86);
     }
     $scale = $fanw / 640;
     // image init
     $image = ImageCreate($fanw, $fanh);
     $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
     ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
     ImageColorTransparent($image, $white);
     $color = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-font-color'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 4, 2)));
     $bgcolor = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-u'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 4, 2)));
     $bgcolorM = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-m'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 4, 2)));
     $bgcolorF = ImageColorAllocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-f'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 4, 2)));
     // imagemap
     $imagemap = '<map id="fanmap" name="fanmap">';
     // loop to create fan cells
     while ($gen >= 0) {
         // clean current generation area
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $fandeg;
         ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
         $rx -= 3;
         // calculate new angle
         $p2 = pow(2, $gen);
         $angle = $fandeg / $p2;
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $angle;
         // special case for rootid cell
         if ($gen == 0) {
             $deg1 = 90;
             $deg2 = 360 + $deg1;
         }
         // draw each cell
         while ($sosa >= $p2) {
             $person = $treeid[$sosa];
             if ($person) {
                 $name = $person->getFullName();
                 $addname = $person->getAddName();
                 $text = I18N::reverseText($name);
                 if ($addname) {
                     $text .= "\n" . I18N::reverseText($addname);
                 }
                 $text .= "\n" . I18N::reverseText($person->getLifeSpan());
                 switch ($person->getSex()) {
                     case 'M':
                         $bg = $bgcolorM;
                         break;
                     case 'F':
                         $bg = $bgcolorF;
                         break;
                     default:
                         $bg = $bgcolor;
                         break;
                 }
                 ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                 // split and center text by lines
                 $wmax = (int) ($angle * 7 / Theme::theme()->parameter('chart-font-size') * $scale);
                 $wmax = min($wmax, 35 * $scale);
                 if ($gen == 0) {
                     $wmax = min($wmax, 17 * $scale);
                 }
                 $text = $this->splitAlignText($text, $wmax);
//.........这里部分代码省略.........
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:101,代码来源:FanchartController.php

示例3: generateFanChart

 /**
  * Generate both the HTML and PNG components of the fan chart
  *
  * The HTML and PNG components both require the same co-ordinate calculations,
  * so we generate them using the same code, but we send them in separate
  * HTTP requests.
  *
  * @param string $what "png" or "html"
  *
  * @return string
  */
 public function generateFanChart($what)
 {
     $treeid = $this->sosaAncestors($this->generations);
     $fanw = 640 * $this->fan_width / 100;
     $fandeg = 90 * $this->fan_style;
     $html = '';
     $treesize = count($treeid) + 1;
     // generations count
     $gen = log($treesize) / log(2) - 1;
     $sosa = $treesize - 1;
     // fan size
     if ($fandeg == 0) {
         $fandeg = 360;
     }
     $fandeg = min($fandeg, 360);
     $fandeg = max($fandeg, 90);
     $cx = $fanw / 2 - 1;
     // center x
     $cy = $cx;
     // center y
     $rx = $fanw - 1;
     $rw = $fanw / ($gen + 1);
     $fanh = $fanw;
     // fan height
     if ($fandeg == 180) {
         $fanh = round($fanh * ($gen + 1) / ($gen * 2));
     }
     if ($fandeg == 270) {
         $fanh = round($fanh * 0.86);
     }
     $scale = $fanw / 640;
     // image init
     $image = imagecreate($fanw, $fanh);
     $white = imagecolorallocate($image, 0xff, 0xff, 0xff);
     imagefilledrectangle($image, 0, 0, $fanw, $fanh, $white);
     imagecolortransparent($image, $white);
     $color = imagecolorallocate($image, hexdec(substr(Theme::theme()->parameter('chart-font-color'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-font-color'), 4, 2)));
     $bgcolor = imagecolorallocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-u'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-u'), 4, 2)));
     $bgcolorM = imagecolorallocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-m'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-m'), 4, 2)));
     $bgcolorF = imagecolorallocate($image, hexdec(substr(Theme::theme()->parameter('chart-background-f'), 0, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 2, 2)), hexdec(substr(Theme::theme()->parameter('chart-background-f'), 4, 2)));
     // imagemap
     $imagemap = '<map id="fanmap" name="fanmap">';
     // loop to create fan cells
     while ($gen >= 0) {
         // clean current generation area
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $fandeg;
         imagefilledarc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
         $rx -= 3;
         // calculate new angle
         $p2 = pow(2, $gen);
         $angle = $fandeg / $p2;
         $deg2 = 360 + ($fandeg - 180) / 2;
         $deg1 = $deg2 - $angle;
         // special case for rootid cell
         if ($gen == 0) {
             $deg1 = 90;
             $deg2 = 360 + $deg1;
         }
         // draw each cell
         while ($sosa >= $p2) {
             $person = $treeid[$sosa];
             if ($person) {
                 $name = $person->getFullName();
                 $addname = $person->getAddName();
                 $text = I18N::reverseText($name);
                 if ($addname) {
                     $text .= "\n" . I18N::reverseText($addname);
                 }
                 $text .= "\n" . I18N::reverseText($person->getLifeSpan());
                 switch ($person->getSex()) {
                     case 'M':
                         $bg = $bgcolorM;
                         break;
                     case 'F':
                         $bg = $bgcolorF;
                         break;
                     default:
                         $bg = $bgcolor;
                         break;
                 }
                 imagefilledarc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                 // split and center text by lines
                 $wmax = (int) ($angle * 7 / Theme::theme()->parameter('chart-font-size') * $scale);
                 $wmax = min($wmax, 35 * $scale);
                 if ($gen == 0) {
                     $wmax = min($wmax, 17 * $scale);
                 }
                 $text = $this->splitAlignText($text, $wmax);
//.........这里部分代码省略.........
开发者ID:tronsmit,项目名称:webtrees,代码行数:101,代码来源:FanchartController.php


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