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


PHP Line::apply方法代码示例

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


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

示例1: apply

 public function apply($resource)
 {
     // Get arguments
     @(list(, $thickness, $color, $sides) = func_get_args());
     $thickness = (int) $thickness;
     if (!$color) {
         $color = '#000000';
     }
     $sides = (int) $sides;
     // Get resolution
     $width = imagesx($resource);
     $height = imagesy($resource);
     if ($width === false || $height === false) {
         throw new Exception("An error was encountered while getting image resolution");
     }
     // Define adjustment
     $z = $thickness / 2;
     // Draw borders
     if ($sides == self::ALL || $sides == self::TOP) {
         parent::apply($resource, 0, $z, $width, $z, $thickness, $color);
     }
     if ($sides == self::ALL || $sides == self::RIGHT) {
         parent::apply($resource, $width - $z, $z, $width - $z, $height, $thickness, $color);
     }
     if ($sides == self::ALL || $sides == self::BOTTOM) {
         parent::apply($resource, $width - $z, $height - $z, 0, $height - $z, $thickness, $color);
     }
     if ($sides == self::ALL || $sides == self::LEFT) {
         parent::apply($resource, $z, $height, $z, 0, $thickness, $color);
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:32,代码来源:Border.php

示例2: apply

 public function apply($resource)
 {
     // Extract arguments
     @(list(, $direction, $step, $thickness, $color) = func_get_args());
     $step = (int) $step;
     $thickness = (int) $thickness;
     if ($step < 2) {
         $step = 2;
     }
     // Get resolution
     $width = imagesx($resource);
     $height = imagesy($resource);
     if ($width === false || $height === false) {
         throw new Exception("An error was encountered while getting image resolution");
     }
     // Apply effect
     switch ($direction) {
         case self::VERTICAL:
             $x = 0;
             while (($x += $step) < $width) {
                 parent::apply($resource, $x, 0, $x, $height, $thickness, $color);
             }
             break;
         case self::HORIZONTAL:
         default:
             $y = 0;
             while (($y += $step) < $height) {
                 parent::apply($resource, 0, $y, $width, $y, $thickness, $color);
             }
     }
     return $resource;
 }
开发者ID:pyrsmk,项目名称:imagix,代码行数:32,代码来源:Lines.php


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