/** * {@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 doGenerate(CanvasInterface $canvas) { $width = $canvas->getWidth(); $height = $canvas->getHeight(); $n = sqrt(pow($width, 2) + pow($height, 2)); $arc = new Arc(null, new Coordinate($width / 2, $height / 2)); $arc->fill(true); for ($i = 0; $i < $n; $i += $this->getStep() + 1) { $arc->getDimension()->resize($n - $i, $n - $i); $arc->setColor($this->getColor($i / $n))->draw($canvas); } }
/** * {@inheritdoc} */ protected function doGenerate(CanvasInterface $canvas) { $width = $canvas->getWidth(); $height = $canvas->getHeight(); $n = max($width, $height) / 2; $rect = new Rectangle(); $rect->fill(true); for ($i = 0; $i < $n; $i += $this->getStep() + 1) { $rect->getStart()->move($i * $width / $height, $i * $height / $width); $rect->getDimension()->resize($width - $i * $width / $height - $rect->getStart()->getX(), $height - $i * $height / $width - $rect->getStart()->getY()); $rect->setColor($this->getColor($i / $n))->draw($canvas); } }
/** * {@inheritdoc} */ protected function doGenerate(CanvasInterface $canvas) { $width = $canvas->getWidth(); $height = $canvas->getHeight(); $ry = $height > $width ? 1 : $width / $height; $rx = $width > $height ? 1 : $height / $width; $n = min($width, $height); $poly = new Polygon(); $poly->fill(true); for ($i = 0; $i < $n; $i += $this->getStep() + 1) { $coordinates = array(new Coordinate($width / 2, $i * $rx - 0.5 * $height), new Coordinate($i * $ry - 0.5 * $width, $height / 2), new Coordinate($width / 2, 1.5 * $height - $i * $rx), new Coordinate(1.5 * $width - $i * $ry, $height / 2)); $poly->setCoordinate(new \ArrayObject($coordinates))->setColor($this->getColor($i / $n))->draw($canvas); } }
/** * {@inheritdoc} */ protected function doGenerate(CanvasInterface $canvas) { $n = $w = null; if (self::GRADIENT_VERTICAL == $this->getType()) { $n = $canvas->getHeight(); $w = $canvas->getWidth(); } else { $w = $canvas->getHeight(); $n = $canvas->getWidth(); } $rect = new Rectangle(); $rect->fill(true); for ($i = 0; $i < $n; $i += $this->getStep() + 1) { if (self::GRADIENT_VERTICAL == $this->getType()) { $rect->getStart()->move(0, $i); $rect->getDimension()->resize($w, $i + $this->getStep()); } else { $rect->getStart()->move($i, 0); $rect->getDimension()->resize($i + $this->getStep(), $w); } $rect->setColor($this->getColor($i / $n))->draw($canvas); } }
/** * {@inheritdoc} */ protected function doApply(CanvasInterface $canvas) { $colors = array(new RGBColor(0, 0, 150, 100), new RGBColor(255, 0, 0, 100), new RGBColor(0, 0, 0, 100), new RGBColor(150, 0, 0, 100), new RGBColor(255, 204, 0, 100), new RGBColor(100, 100, 100, 100)); $width = round($canvas->getWidth() / 6); $dimension = new Dimension($width, $canvas->getHeight()); $rect = new Rectangle($dimension); $rect->fill(true); for ($i = 0; $i < 6; $i++) { $rect->getStart()->move($width * $i, 0); $rect->setColor($colors[$i])->draw($canvas); } $actions = array(new Smooth(20), new Color\Contrast(35)); foreach ($actions as $action) { $action->apply($canvas); } }
/** * {@inheritdoc} */ protected function doApply(CanvasInterface $canvas) { $width = $canvas->getWidth(); $height = $canvas->getHeight(); $mirrorPoint = null; $srcBox = null; $destBox = null; switch ($this->getdirection()) { case self::MIRROR_VERTICAL: $mirrorPoint = $width / 2; $srcBox = new Box(new Dimension(-$mirrorPoint, $height), new Coordinate($mirrorPoint - 1, 0)); $destBox = new Box(new Dimension($mirrorPoint, $height), new Coordinate($mirrorPoint, 0)); break; case self::MIRROR_HORIZONTAL: $mirrorPoint = $height / 2; $srcBox = new Box(new Dimension($width, -$mirrorPoint), new Coordinate(0, $mirrorPoint - 1)); $destBox = new Box(new Dimension($width, $mirrorPoint), new Coordinate(0, $mirrorPoint)); break; } $canvas->paste($canvas, $srcBox, $destBox); }
/** * {@inheritdoc} */ protected function doApply(CanvasInterface $canvas) { $width = $canvas->getWidth(); $height = $canvas->getHeight(); $line = new Line(); $line->setColor($this->getColor()); for ($x = 1; $x <= $width; $x += $this->getSize()) { $line->getStart()->move($x, 0); $line->getEnd()->move($x, $height); $line->draw($canvas); } for ($y = 1; $y <= $height; $y += $this->getSize()) { $line->getStart()->move(0, $y); $line->getEnd()->move($width, $y); $line->draw($canvas); } }
/** * {@inheritdoc} */ protected function doApply(CanvasInterface $canvas) { $c1 = clone $this->getFirstColor(); $c2 = clone $this->getSecondColor(); $line = new Line(); $width = $canvas->getWidth(); $height = $canvas->getHeight(); for ($i = 0; $i < $this->getWidth(); $i++) { $alpha = round($i / $this->getWidth() * 127); $c1->setAlpha($alpha); $c2->setAlpha($alpha); $line->setStart(new Coordinate($i, $i + 1))->setEnd(new Coordinate($i, $height - $i - 1))->setColor($c1)->draw($canvas)->setStart(new Coordinate($i, $i))->setEnd(new Coordinate($width - $i, $i))->draw($canvas)->setStart(new Coordinate($width - $i, $height - $i - 1))->setEnd(new Coordinate($width - $i, $i + 1))->setColor($c2)->draw($canvas)->setStart(new Coordinate($width - $i, $height - $i - 1))->setEnd(new Coordinate($i, $height - $i))->draw($canvas); } }