Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }