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


PHP sfImage::fill方法代码示例

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


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

示例1: addPadding

 /**
  * Adds any padding to the given image using the supplied padding config
  * 
  * @param $img
  * @param array $padding
  * @return $img
  */
 private function addPadding($img, $padding)
 {
     if (!$padding) {
         return $img;
     }
     if (isset($padding['percent']) && is_numeric($padding['percent'])) {
         $width = $img->getWidth() * (1 + $padding['percent'] / 100);
         $height = $img->getHeight() * (1 + $padding['percent'] / 100);
     } else {
         if (isset($padding['pixels']) && is_numeric($padding['pixels'])) {
             $width = $img->getWidth() + $padding['pixels'];
             $height = $img->getHeight() + $padding['pixels'];
         } else {
             return $img;
         }
     }
     $canvas = new sfImage();
     $canvas->fill(0, 0, isset($padding['color']) ? $padding['color'] : '#ffffff')->resize($width, $height)->overlay($img, 'center');
     return $canvas;
 }
开发者ID:retrofox,项目名称:Huemul,代码行数:27,代码来源:JCroppable.php

示例2: transform

 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     $resource_w = $image->getWidth();
     $resource_h = $image->getHeight();
     $scale_w = $this->getWidth() / $resource_w;
     $scale_h = $this->getHeight() / $resource_h;
     switch ($this->getMethod()) {
         case 'deflate':
         case 'inflate':
             return $image->resize($this->getWidth(), $this->getHeight());
         case 'left':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop(0, (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'right':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop($image->getWidth() - $this->getWidth(), (int) round(($image->getHeight() - $this->getHeight()) / 2), $this->getWidth(), $this->getHeight());
         case 'top':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), 0, $this->getWidth(), $this->getHeight());
         case 'bottom':
             $image->scale(max($scale_w, $scale_h));
             return $image->crop((int) round(($image->getWidth() - $this->getWidth()) / 2), $image->getHeight() - $this->getHeight(), $this->getWidth(), $this->getHeight());
         case 'center':
             $image->scale(max($scale_w, $scale_h));
             $left = (int) round(($image->getWidth() - $this->getWidth()) / 2);
             $top = (int) round(($image->getHeight() - $this->getHeight()) / 2);
             return $image->crop($left, $top, $this->getWidth(), $this->getHeight());
         case 'scale':
             return $image->scale(min($scale_w, $scale_h));
         case 'fit':
         default:
             $img = clone $image;
             $image->create($this->getWidth(), $this->getHeight());
             // Set a background color if specified
             if (!is_null($this->getBackground()) && $this->getBackground() != '') {
                 $image->fill(0, 0, $this->getBackground());
             }
             $img->scale(min($this->getWidth() / $img->getWidth(), $this->getHeight() / $img->getHeight()));
             $image->overlay($img, 'center');
             return $image;
     }
 }
开发者ID:nageshwar545,项目名称:PluginsKit,代码行数:45,代码来源:sfImageThumbnailGeneric.php

示例3: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     imagesetthickness($resource, $this->thickness);
     if (!is_null($this->fill)) {
         if (!is_object($this->fill)) {
             imagefilledellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->fill));
         }
         if (is_object($this->fill)) {
             imagefilledellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
             $image->fill($this->x, $this->y, $this->fill);
         }
         if ($this->color !== "" && $this->fill !== $this->color) {
             imageellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
         }
     } else {
         imageellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
     }
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:26,代码来源:sfImageEllipseGD.class.php

示例4: transform

 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     if (!is_null($this->style)) {
         imagesetstyle($resource, $this->style);
     }
     imagesetthickness($resource, $this->thickness);
     if (!is_null($this->fill)) {
         if (!is_object($this->fill)) {
             imagefilledrectangle($resource, $this->x1, $this->y1, $this->x2, $this->y2, $image->getAdapter()->getColorByHex($resource, $this->fill));
         }
         if ($this->getColor() !== "" && $this->fill !== $this->getColor()) {
             imagerectangle($resource, $this->x1, $this->y1, $this->x2, $this->y2, $image->getAdapter()->getColorByHex($resource, $this->getColor()));
         }
         if (is_object($this->fill)) {
             $image->fill($this->x1 + $this->thickness, $this->y1 + $this->thickness, $this->fill);
         }
     } else {
         imagerectangle($resource, $this->x1, $this->y1, $this->x2, $this->y2, $image->getAdapter()->getColorByHex($resource, $this->getColor()));
     }
     return $image;
 }
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:28,代码来源:sfImageRectangleGD.class.php


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