/**
  * {@inheritdoc}
  */
 public function draw(CanvasInterface $canvas, Border $border, StyleInterface $style = null)
 {
     $rect = new Rectangle($canvas->getDimension());
     $color = $style ? $style->apply($canvas, $border) : $border->getColor();
     $rect->setColor($color)->setLineThickness($border->getSize())->draw($canvas);
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $width = $canvas->getWidth();
     $height = $canvas->getHeight();
     $copy = new \Jaguar\Canvas($canvas->getDimension());
     $srcBox = null;
     $destBox = null;
     switch ($this->getDirection()) {
         case self::FLIP_VERTICAL:
             $srcBox = new Box(new Dimension($width, -$height), new Coordinate(0, $height - 1));
             $destBox = new Box(new Dimension($width, $height), new Coordinate(0, 0));
             break;
         case self::FLIP_HORIZONTAL:
             $srcBox = new Box(new Dimension(-$width, $height), new Coordinate($width - 1, 0));
             $destBox = new Box(new Dimension($width, $height), new Coordinate(0, 0));
             break;
         case self::FLIP_BOTH:
             $srcBox = new Box(new Dimension(-$width, -$height), new Coordinate($width - 1, $height - 1));
             $destBox = new Box(new Dimension($width, $height), new Coordinate(0, 0));
             break;
     }
     $copy->paste($canvas, $srcBox, $destBox);
     $canvas->destroy();
     $canvas->setHandler($copy->getHandler());
 }
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $dimension = $canvas->getDimension();
     $newDimension = new Dimension(2, $dimension->getHeight());
     for ($i = 0; $i < $dimension->getWidth(); $i += 2) {
         $canvas->paste($canvas, new Box($newDimension, new Coordinate($i, 0)), new Box($newDimension, new Coordinate($i - 2, sin($i / 10) * $this->getLevel())));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function draw(CanvasInterface $canvas, Border $border, StyleInterface $style = null)
 {
     $size = $border->getSize();
     $new = new Canvas($canvas->getDimension());
     $new->paste($canvas, null, new Box($canvas->getDimension()->translate(-$size, -$size + 1), new Coordinate($size / 2, $size / 2)));
     $in = new BorderIn();
     $in->draw($new, $border, $style);
     $canvas->destroy();
     $canvas->setHandler($new->getHandler());
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 protected function doApply(CanvasInterface $canvas)
 {
     $box = is_null($this->getBox()) ? new Box($canvas->getDimension()) : $this->getBox();
     $compine = new \Jaguar\Canvas($canvas->getDimension());
     $compine->paste($canvas);
     $compine->paste($this->getOverlay(), null, $box);
     imagelayereffect($canvas->getHandler(), IMG_EFFECT_OVERLAY);
     imagecopymerge($canvas->getHandler(), $compine->getHandler(), 0, 0, 0, 0, $canvas->getWidth(), $canvas->getHeight(), $this->getAmount());
     $canvas->alphaBlending(true);
     $compine->destroy();
 }
 /**
  * {@inheritdoc}
  */
 public function paste(CanvasInterface $src, Box $srcBox = null, Box $destBox = null)
 {
     $this->assertEmpty();
     if (!$src->isHandlerSet()) {
         throw new CanvasEmptyException('Could Not Execute Paste - Source Canvas Handler Is Not Set');
     }
     $srcDimension = $src->getDimension();
     $srcBox = $srcBox === null ? new Box($srcDimension) : $srcBox;
     $destBox = $destBox === null ? new Box($srcDimension) : $destBox;
     $this->preserveAlpha($this->getHandler(), $src->getHandler());
     $this->preserveAlpha($src->getHandler(), $this->getHandler());
     if (false == @imagecopyresampled($this->getHandler(), $src->getHandler(), $destBox->getX(), $destBox->getY(), $srcBox->getX(), $srcBox->getY(), $destBox->getWidth(), $destBox->getHeight(), $srcBox->getWidth(), $srcBox->getHeight())) {
         throw new CanvasException(sprintf('Could Not Paste "%s" On "%s"', (string) $src, (string) $this));
     }
     return $this;
 }