/** * {@inheritdoc} */ protected function doApply(CanvasInterface $canvas) { $copy = new \Jaguar\Canvas($this->getDimension()); $copy->paste($canvas, null, new Box($this->getDimension())); $canvas->destroy(); $canvas->setHandler($copy->getHandler()); }
/** * {@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()); }
/** * @dataProvider actionFilesProvider * * @param string $file * @param \Jaguar\Action\Rotate $action * @param \Jaguar\Dimension $expectedDimension */ public function testApply($file, Rotate $action, \Jaguar\Dimension $expectedDimension) { $canvas = new \Jaguar\Canvas(); $canvas->fromFile($file); $this->assertInstanceOf('\\Jaguar\\Action\\Rotate', $action->apply($canvas)); $this->assertTrue($canvas->getDimension()->equals($expectedDimension)); }
/** * {@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(); }