GoodBoyDigital/pixi.js — pull request #1053 by gordyr (2014-10-16 07:19:43+00:00)
Title: Added Convolution filter

This adds a convolution filter which accepts a matrix (specified as a 9 point Array) It can be used to create many further effects such as sharpen, emboss, blurs, edge detection and more. see http://docs.gimp.org/en/plug-in-convmatrix.html for more info.

As you can see it currently requires three parameters:

```
matrix = [
0, -1, 0,
-1, 5, -1,
0, -1, 0
];

width = texture width;
height = texture height;
```

Ideally we should be able to access the texture dimensions inside the filter class but I couldn't find anywhere to do so for now I have left them as parameters to pass. I am very inexperienced with pixi.js and didn't have time to go poking about too much.

I have already created sharpen, emboss, edge detection and edge enhance filters with this.

For example:

```
/*
* SHARPEN
*/

var sharpen = function(amount){
var a = amount || 1;
return [
0, -1*a, 0,
-1*a, 1 + 4*a, -1*a,
0, -1*a, 0
];
}

var filter = new PIXI.ConvolutionFilter(sharpen(3), texWidth, texHeight);
```

I have these wrapped up into furthe pixi filter classes so that you can simply do:

```
var sharpen = new PIXI.SharpenFilter(3, texWidth, texHeight);
```

But before submitting them I would like to see if we can get the texture dimensions internally first, as mentioned above.

I have also written both ```Lancosz``` and ```bicubic``` filters if you are interested. We are using pixi.js for photo related stuff so i'm not sure how relevant they would be to you.