Skip to content

Commit

Permalink
Introduce blur effect (contao#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
chregu authored and ausi committed Mar 1, 2018
1 parent ff94280 commit 6d9951a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
65 changes: 65 additions & 0 deletions src/Effects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php


namespace Contao\ImagineSvg;


use Imagine\Effects\EffectsInterface;
use Imagine\Exception\RuntimeException;
use Imagine\Image\Palette\Color\ColorInterface;

class Effects implements EffectsInterface
{

/** @var Image */
private $image;

public function __construct(Image $image)
{
$this->image = $image;
}

public function gamma($correction)
{
throw new RuntimeException('This method is not implemented');

// TODO: Implement gamma() method.
}

public function negative()
{
throw new RuntimeException('This method is not implemented');
// TODO: Implement negative() method.
}

public function grayscale()
{
throw new RuntimeException('This method is not implemented');
// TODO: Implement grayscale() method.
}

public function colorize(ColorInterface $color)
{
throw new RuntimeException('This method is not implemented');
// TODO: Implement colorize() method.
}

public function sharpen()
{
throw new RuntimeException('This method is not implemented');
// TODO: Implement sharpen() method.
}

public function blur($sigma)
{

$dom = $this->image->getDomDocument();
$dom->documentElement->setAttribute("filter", "url(#rokkaBlur)");
$filter = $dom->createDocumentFragment();
$filter->appendXML('<filter id="rokkaBlur">
<feGaussianBlur in="SourceGraphic" stdDeviation="'.$sigma.'" />
</filter>');
$dom->documentElement->insertBefore($filter, $dom->documentElement->firstChild);
}

}
2 changes: 1 addition & 1 deletion src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function draw()
*/
public function effects()
{
throw new RuntimeException('This method is not implemented');
return new Effects($this);
}

/**
Expand Down

0 comments on commit 6d9951a

Please sign in to comment.